I got a simple iteration going on <% @user.sender.each do |sender| %> ... <% end %> Can I fetch and display for example only 2 items from my database insted of all 4 of them ? Is there a better way to do this ? I could use will_paginate on the iteration (per_page => 2) but I don`t want the links to show up. Cata -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
limiting the Find method in the controller. eg: @user = User.find(:all, :limit => 2) Hope it helps! On Apr 21, 11:27 pm, Babos Catalin <li...-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> wrote:> I got a simple iteration going on > > <% @user.sender.each do |sender| %> > ... > <% end %> > > Can I fetch and display for example only 2 items from my database insted > of all 4 of them ? > > Is there a better way to do this ? > I could use will_paginate on the iteration (per_page => 2) but I don`t > want the links to show up. > > Cata > -- > Posted viahttp://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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. > For more options, visit this group athttp://groups.google.com/group/rubyonrails-talk?hl=en.-- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@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?hl=en.
Hi> I got a simple iteration going on > > <% @user.sender.each do |sender| %> > ... > <% end %> > > Can I fetch and display for example only 2 items from my database insted > of all 4 of them ?in controller @sender = @user.sender.find(:all,:limit => 2) in view <% @sender.each do |s| %> Sijo -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Babos Catalin wrote:> I got a simple iteration going on > > <% @user.sender.each do |sender| %> > ... > <% end %> > > Can I fetch and display for example only 2 items from my database insted > of all 4 of them ? > > Is there a better way to do this ? > I could use will_paginate on the iteration (per_page => 2) but I don`t > want the links to show up. > > CataWhich two are you interested in seeing? The first two, or two with certain attributes. Is this a space issue or a selection issue? You could create a named scope I think, then refer to @user.special_senders.each do |sender| where the special_senders scope limits the associated senders to only those you want. -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Sijo k g wrote:> Hi >> I got a simple iteration going on >> >> <% @user.sender.each do |sender| %> >> ... >> <% end %> >> >> Can I fetch and display for example only 2 items from my database insted >> of all 4 of them ? > > in controller @sender = @user.sender.find(:all,:limit => 2) > > in view > <% @sender.each do |s| %> > > > > SijoThank you very much, that did the trick. It was a selection issue and I think I will use a named scope later on. Cata -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.