Presently, it is possible to order model records by calling the ::all method on a specific model class and then the #order method on the obtained query set. Let's make this process simpler by adding an ::order method to model classes.
That way, it would become possible to do:
User.order(:first_name, :last_name) # Get all User records ordered by first name first and then by last name
Description
Presently, it is possible to order model records by calling the
::all
method on a specific model class and then the#order
method on the obtained query set. Let's make this process simpler by adding an::order
method to model classes.That way, it would become possible to do: