Hai I need one help from you guys I have three tables ,from that tables i am getting the document details and i am displaying the document titles,actually i am displaying 5 titles only in the page,after i am giving the more link to paginate I dont know how to paginate across all the document titles can any body tell me the solution ok Bye By P.S.Hussain -- 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-/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 -~----------~----~----~----~------~----~------~--~---
Hi Hussain, Mohamed Hussain wrote:> I dont know how to paginate across all the document titlesMike Gary made an excellent post on this topic just last week. I''ve copied it below. HTH, Bill From: "Mike Garey" <random52k-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> To: <rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org> Sent: Thursday, July 12, 2007 4:43 PM Subject: [Rails] Newbies: Read this before asking about pagination> > I''ve just read three* different messages on the list, all posted > within a day of each other, and all having problems with the same > thing - rails built in pagination. > > The common misconception seems to be that rails built in pagination > works as follows: > > # grab a list of all the females > @users = User.find(:all, :conditions => [''gender = ?'', ''F'']) > > # paginate the list: > @user_pages, @users = paginate(:users, :per_page => 10) > > The above will paginate a list of users, however, it will NOT have the > conditions applied to it that you specified in the first find > statement (grabbing a list of females). The two statements are not > related to each other. The first finds all the females and stores the > results in the @users instance variable. The second finds and > paginates _ALL_ of the users and stores them in the @users ivar, > overwriting the original contents. This is most likely _not_ what you > want. > > If you wanted to paginate a list of all the females, the correct way > to do it is the following > > # paginate a list of females > @user_pages, @users = paginate(:users, :conditions => [''gender = ?'', > ''F''], :per_page => 10) > > now, having said that, please be aware that the rails built in > pagination has been deprecated! (see here for more details > http://dev.rubyonrails.org/changeset/6992) In other words, do not use > it for future projects! > > Instead, you should be using something like the will_paginate plugin > (you can read about it here: http://errtheblog.com/post/4791) > > Hopefully this will help reduce some confusion.. > > Mike >--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
When using the pagination class, you can specify the :include parameter. Is it possible to specify two for a table that references two relations? For example a POST has both a USER and an ORGANIZATION. Would the correct syntax be: @posts_pages, @posts = paginate(:posts, :include => :user, :include => :organizations, :order => ''published_at DESC'', :conditions => "organization_id=#{params[:organization_id].to_i} AND published = true") --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
mindtonic-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org wrote:> When using the pagination class, you can specify the :include > parameter. Is it possible to specify two for a table that references > two relations? For example a POST has both a USER and an > ORGANIZATION. Would the correct syntax be: > > @posts_pages, @posts = paginate(:posts, > :include => :user, > :include => :organizations, > :order => ''published_at DESC'', > :conditions => "organization_id=#{params[:organization_id].to_i} > AND published = true")According to the API docs, paginate will pass the include options onto #find which in turn would expect an array, so: :include => [:user, :organisation] is the way to do it. -- Cheers, - Jacob Atzen --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Many Thanks --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---