diff --git a/app/controllers/blogposts_controller.rb b/app/controllers/blogposts_controller.rb index 92beb68..79c9e5d 100644 --- a/app/controllers/blogposts_controller.rb +++ b/app/controllers/blogposts_controller.rb @@ -9,6 +9,7 @@ class BlogpostsController < ApplicationController def show @comment = Comment.new(blogpost: @post) + @comments = @post.comments.page(params[:page]) end def new diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index 967c6c4..c1b738a 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -22,7 +22,7 @@ class UsersController < ApplicationController @users = User.where.not(id: User.first.id) #Remove first user end @users = @users.order("role_id desc", "confirmed desc", :name) - @count = @users.length + @count = @users.size @users = @users.page(params[:page]).per(100) end diff --git a/app/views/blogposts/show.html.erb b/app/views/blogposts/show.html.erb index 0dae530..57532dc 100644 --- a/app/views/blogposts/show.html.erb +++ b/app/views/blogposts/show.html.erb @@ -17,9 +17,10 @@
<%= "#{pluralize(@post.comments.length, 'comment')}." %>
- <% @post.comments.each do |c| %> +<%= "#{pluralize(@post.comments.size, 'comment')}." %>
+ <% @comments.each do |c| %> <%= render "comments/comment", c: c %> <% end %> + <%= paginate @comments %> <%= render "comments/new" %>