Order by date

Abdullah Jibaly
Sun, 24 Jul 2005 15:33:01 -0000

Hi all,

In Agile Web Dev w/Rails it is shown how to order a collection by date as:

# Return a list of products we can sell (which means they have to be
# available). Show the most recently available first.
def self.salable_items
  find(:all,
       :conditions => "date_available <= now()",
       :order      => "date_available desc")
end

What if I do not want to be tied to MySQL (the now function)? If I want to
migrate to another db I''d have to change my source code, which is not
good,
right? What is a better alternative?

Thanks,
Abdullah