How can you control what to list and what not to in a paginate? @content_pages, @contents = paginate :contents, :per_page => 10 And how do I access any related data? -- 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 -~----------~----~----~----~------~----~------~--~---
Pål Bergström wrote:> How can you control what to list and what not to in a paginate? > > @content_pages, @contents = paginate :contents, :per_page => 10 > > And how do I access any related data? > > -- > Posted via http://www.ruby-forum.com/.you can pass an :order or :conditions to the paginate function to limit your results or sort them. The results are stored in the @contents instance variable _Kevin --~--~---------~--~----~------------~-------~--~----~ 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@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk -~----------~----~----~----~------~----~------~--~---
_Kevin wrote:> P�l Bergstr�m wrote: >> How can you control what to list and what not to in a paginate? >> >> @content_pages, @contents = paginate :contents, :per_page => 10 >> >> And how do I access any related data? >> >> -- >> Posted via http://www.ruby-forum.com/. > > you can pass an :order or :conditions to the paginate function to limit > your results or sort them. The results are stored in the @contents > instance variable > > _KevinOrder I know of, and also that you can have conditions but not sure what to put in there? Do you mean conditions as in a find? (sorry for a possibly stupid question) -- 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@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk -~----------~----~----~----~------~----~------~--~---
_Kevin wrote:> P�l Bergstr�m wrote: >> How can you control what to list and what not to in a paginate? >> >> @content_pages, @contents = paginate :contents, :per_page => 10 >> >> And how do I access any related data? >> >> -- >> Posted via http://www.ruby-forum.com/. > > you can pass an :order or :conditions to the paginate function to limit > your results or sort them. The results are stored in the @contents > instance variable > > _KevinConditions doesn''t give you the possibility to show the columns you want, or? -- 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@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk -~----------~----~----~----~------~----~------~--~---
Pål Bergström wrote:> Conditions doesn''t give you the possibility to show the columns you > want, or?Any help with this is appreciated. I''m kind of stuck. -- 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@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk -~----------~----~----~----~------~----~------~--~---
> Conditions doesn''t give you the possibility to show the columns you > want, or?The Paginator object does not contain your other objects. You need to find them like so (from the api docs): def list @person_pages = Paginator.new self, Person.count, 10, params[:page] @people = Person.find :all, :order => ''last_name, first_name'', :limit => @person_pages.items_per_page, :offset => @person_pages.current.offset end One thing to watch out for is the Person.count. If you have conditions, you''ll need to run a count query with those conditions first: def list conditions = ["people.last_name like ''?%''", params[:letter]] count = Person.count(:all, :conditions => conditions) @person_pages = Paginator.new(self, count, 10, params[:page]) @people = Person.find :all, :order => ''last_name, first_name'', :conditions => conditions, :limit => @person_pages.items_per_page, :offset => @person_pages.current.offset end Now, I''m reading the docs and it appears the above method is the classic way to do it, and the same can now be achieved with: def list @person_pages, @people paginate :people, :conditions => ["people.last_name like ''?%''", params[:letter]] :order => ''last_name, first_name'' end Anyone know from experience if this is so? -- 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 -~----------~----~----~----~------~----~------~--~---
Pål, It also appears that paginate will accept a :select parameter if you want to specify columns. -- 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@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk -~----------~----~----~----~------~----~------~--~---
Curtis Summers wrote: Thanks Curtis :-) I think I understand it better now. I should use <%= @contents.each do |dada| %> -- 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 -~----------~----~----~----~------~----~------~--~---
Curtis Summers wrote:> Pål, > > It also appears that paginate will accept a :select parameter if you > want to specify columns.That''s great. I''ll try it. -- 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@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk -~----------~----~----~----~------~----~------~--~---
Pål Bergström wrote:> Curtis Summers wrote: >> Pål, >> >> It also appears that paginate will accept a :select parameter if you >> want to specify columns. > > That''s great. I''ll try it.It works. The only problem is that I get an error message saying columns are missing. I assume it has to do with: <% for column in Abc.content_columns %> Is there a way to solve this? -- 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@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk -~----------~----~----~----~------~----~------~--~---