0

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.

Community
  • 1
  • 1
user2857014
  • 507
  • 3
  • 10
  • 22
  • You can still access the User objects inside @users I suppose, so you can probably keep the same code. – bo-oz Dec 06 '15 at 19:29
  • I am not sure what the resulting html file would look like. If I keep the current html code and put the '<%= paginate @users %>' , the latter does not have any impact. – user2857014 Dec 06 '15 at 19:36
  • paginate method probably only creates a pagination widget... in the view it doesn't impact the content of `@users`. So the image is available inside the `@users` as it would be normally. – bo-oz Dec 06 '15 at 21:36

0 Answers0