I have a rails application in which pages has many comments. So the relationships in the models are:
page.rb: has_many :comments
comment.rb: belongs_to :page
Now I display the comments in my view by doing:
<% @page.comments.each_with_index do |comment| %>
<%= comment.comment %>
<%end%>
I want to know how I can paginate this with will_paginate. I also want to make it so that the newest one (one with greatest id shows up first). Any ideas?
To order the comments:
To use will_paginate just push the logic into your controller: