Dynamic finders vs. standard find(:all) with condition

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?

Bah I’m an idiot. Disregard this. I forgot to use find_all_by_status
instead of find_by_status.

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs