Is there a difference between the way collections are returned using a
dynamic finder and a standard find all with a condition?
I decided to convert this...
@reservations = Reservation.find(:all, :conditions => ["status =
?",
"Pending"])
...to this...
@reservations = Reservation.find_by_status("Pending")
...because it''s much more readable and I prefer dynamic finders over
conditions whenever possible. However, the collection returned by the
dynamic finder apparently doesn''t have the "empty?" method
available to
it. I use @reservations.empty? in my view to evaluate if I have an
empty collection of objects and react accordingly.
Is there something I''m missing? Do dynamic finders return objects in a
different manner than regular finds?
--
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
-~----------~----~----~----~------~----~------~--~---
Andrew Hite
2007-Feb-26 20:53 UTC
Re: Dynamic finders vs. standard find(:all) with condition
Bah I''m an idiot. Disregard this. I forgot to use find_all_by_status instead of find_by_status. -- 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 -~----------~----~----~----~------~----~------~--~---