I am using kaminari library, and I want to display users' pictures.
In my UserController, I put
def index
@users = User.order(:name).page params[:page]
end
Before, I was accessing the pictures like
#users.transitions-enabled
- @users.each do |user|
- user.pictures.each do |pic|
.box.panel.panel-default
= link_to (image_tag(pic.image.url(:origin))), user
I am now wondering how I can display images by using the following command:
<%= paginate @users %>
Edit:
Now I changed the code in UserController to
@users = User.all
@pictures = @users.pictures.page(params[:page]).per(2)
And it is giving me the error
undefined method `total_pages' for nil:NilClass
I was following the answer here but I am not sure how I can apply it in my case.