I have three relevant models. A User which has_many :photos
and belongs_to :dorm
, a Dorm which has_many :users
and has_many :photos, :through => :users
, and a Photo class which belongs_to :users
and belongs_to :dorm
.
I want to paginate all the photos that are in a dorm with kaminari. I have it in my Gemfile and ran the bundle command.
In my dorms_controller:
@dorm=Dorm.find(params[:id])
@photos=@dorm.photos.page(params[:page]).per(3)
and in my Dorm show view (actually in a partial, _index.html.erm rendered in the show view):
<%= paginate @photos %>
This gives me the error: undefined method 'page' for #<Class:0x107483d68>
.
I know why this doesn't work (shouldn't be called on a class), but I don't know how to make it work...