There are actually many ways to do this using Active Record. The one that was not mentioned above will be (in different formats, all valid):
Model.order(foo: :asc).order(:bar => :desc).order(:etc)
This may be more verbose, but itβs easier for me personally to manage. SQL is created in just one step:
SELECT "models".* FROM "models" ORDER BY "models"."etc" ASC, "models"."bar" DESC, "models"."foo" ASC
So for the original question:
Model.order(:updated_at).order(:price)
You do not need to declare a data type, ActiveRecord does it smoothly, and your DB Engine
Ruby Racer Jan 11 '14 at 9:52
source share