On 27/05/2009, at 7:32 PM, Vipin wrote:
> > >>> so basically, I must use >>> <% if @forms.count != 0 %> >> >> @forms.any? is slightly more idiomatic ruby > > <% if @forms.any? %> > is working and i believe it doesn't have the penalty of SQL query > too. > @forms.count won't work because @forms will most likely be an Array object, and an Array doesn't respond to count... it'll respond to size, tho... @forms.size != 0 or you could do this unless(@forms.blank?) None of these will do a db connection because @forms contains objects which have already been loaded (if they're from the database). Julian. ---------------------------------------------- Learn: http://sensei.zenunit.com/ Last updated 20-May-09 (Rails, Basic Unix) Blog: http://random8.zenunit.com/ Twitter: http://twitter.com/random8r > thanks > vipin > > > > --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---