Hi, I have just installed will_paginate plugin and got it working OK. Excuse me if this is a very obvious question but how do you get access to the total record count from all pages. ie I want to display "nnn matching records"... followed by the <%will_paginate @records %> With the old rails pagination I am using count_collection_for_pagination which I always thought was a bit tacky. Cheers Giorgio --~--~---------~--~----~------------~-------~--~----~ 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Use the count method in AR, ex: User.countRails api docs is a good reference. On Feb 11, 2008 5:08 PM, giorgio <george.peverell-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> > > Excuse me if this is a very obvious question but how do you get access > to the total record count from all pages. > > ie I want to display "nnn matching records"... followed by the <%> will_paginate @records %> > > >-- http://www.rubyplus.org/ Free Ruby and Rails Screencasts --~--~---------~--~----~------------~-------~--~----~ 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Surely the will_paginate plugin must have its own count? I could easily do a count on the database but that is an extra call that presumably the will_paginate has already done? G. On Feb 12, 2:31 pm, "Bala Paranj" <bcpar...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Use the count method in AR, ex: User.countRails api docs is a good > reference. > > On Feb 11, 2008 5:08 PM, giorgio <george.pever...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > > > Excuse me if this is a very obvious question but how do you get access > > to the total record count from all pages. > > > ie I want to display "nnn matching records"... followed by the <%> > will_paginate @records %> > > --http://www.rubyplus.org/ > Free Ruby and Rails Screencasts--~--~---------~--~----~------------~-------~--~----~ 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Looking through the tests in will_paginate plugin, I think you can use the size method. def test_simple_paginate entries = Topic.paginate :page => nil assert_equal 1, entries.current_page assert_nil entries.previous_page assert_nil entries.next_page assert_equal 1, entries.page_count assert_equal 4, entries.size entries = Topic.paginate :page => 2 assert_equal 2, entries.current_page assert_equal 1, entries.previous_page assert_equal 1, entries.page_count assert entries.empty? # :page parameter in options is required! assert_raise(ArgumentError){ Topic.paginate } assert_raise(ArgumentError){ Topic.paginate({}) } end Enjoy! On Feb 11, 2008 6:01 PM, giorgio <george.peverell-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> > Surely the will_paginate plugin must have its own count? > I could easily do a count on the database but that is an extra call > that presumably the will_paginate has already done? > > G. > > On Feb 12, 2:31 pm, "Bala Paranj" <bcpar...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > Use the count method in AR, ex: User.countRails api docs is a good > > reference. > > > > On Feb 11, 2008 5:08 PM, giorgio <george.pever...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > > > > > > > Excuse me if this is a very obvious question but how do you get access > > > to the total record count from all pages. > > > > > ie I want to display "nnn matching records"... followed by the <%> > > will_paginate @records %> > > > > --http://www.rubyplus.org/ > > Free Ruby and Rails Screencasts > > >-- http://www.rubyplus.org/ Free Ruby and Rails Screencasts --~--~---------~--~----~------------~-------~--~----~ 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Try using the total_entries method @posts = Post.paginate_by_board_id @board.id, :page => params[:page], :order => ''updated_at DESC'' total_records = @posts.total_entries On Feb 11, 9:01 pm, giorgio <george.pever...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Surely thewill_paginateplugin must have its own count? > I could easily do a count on the database but that is an extra call > that presumably thewill_paginatehas already done? > > G. > > On Feb 12, 2:31 pm, "Bala Paranj" <bcpar...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > Use the count method in AR, ex: User.countRails api docs is a good > > reference. > > > On Feb 11, 2008 5:08 PM, giorgio <george.pever...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > > Excuse me if this is a very obvious question but how do you get access > > > to thetotalrecord count from all pages. > > > > ie I want to display "nnn matchingrecords"... followed by the <%> > >will_paginate@records%> > > > --http://www.rubyplus.org/ > > Free Ruby and Rails Screencasts--~--~---------~--~----~------------~-------~--~----~ 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---