Sup! I have
@comment = @photo.comments.create(...)
And I need to paginate this comments somehow, in the view:
- @photo.comments.each do |comment|
...
But I'm stucked, so help me please.
Do I need define @comments
to add pagination?
Ya I think we need to define @comments.
In controller -
@comments = @photo.comments.page(params[:page])
In view -
<% @comments.each do |comment| %>
<%= comment.attribute_name %>
<% end %>
<%= paginate @comments %>
I tried this and it worked.