Patrick Heneise wrote: > Hi Folks > > is there any way to link to the last page of a paginated list, if the > number of pages is not available in this moment? For example a forum > with topic and replies. I'd like to link to the last page of the > replies, but I don't know how many pages there are in the forum view? > I'm using mislav-will_paginate for pagination. > > Thank you in advance!
If you have an object that you have paginated, you can get the number of pages with .total_pages: this will be the same as the number of the last page. Presumably when you're looking at the topic, you've already loaded it's replies anyway? eg @topic = Topic.find(params[:id]) @replies = @topic.replies.paginate(:page => 1, :per_page => 20) last_page = @replies.total_pages -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk@googlegroups.com To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---