You are here: Browse Railsplugins Default Order
Author : Antonin AMAND Email : aamand@gwikzone.org
The default_order plugin provides a ‘order_by’ method to be called in your models.
ex :
class Contact < ActiveRecord::Base order_by “first_name, last_name”
end
the order_by method will append the given argument to :order Hash key of ActiveRecord::Base.find method IF IT HAS NOT BEEN PROVIDED.
ex :
Contact.find(:all, :conditions => “last_name LIKE ‘toto’”)If you use those attributes in other models, you may want to specify the table_name :
class Contact < ActiveRecord::Base order_by “contacts.first_name, contacts.last_name”
end
NOTE: This description has been extracted from the Plugin README and so the formatting may need updating to make browser friendly