5 Email : aamand@gwikzone.org
7 The default_order plugin provides a 'order_by' method to
8 be called in your models.
12 class Contact < ActiveRecord::Base
13 order_by "first_name, last_name"
17 the order_by method will append the given argument to
18 :order Hash key of ActiveRecord::Base.find method
19 IF IT HAS NOT BEEN PROVIDED.
23 Contact.find(:all, :conditions => "last_name LIKE '%toto%'")
24 # will act as if you had written this
25 Contact.find(:all, :order => "last_name, first_name",
26 :conditions => "last_name LIKE '%toto%'")
27 # but if you provide :order it will override the default order
29 If you use those attributes in other models, you
30 may want to specify the table_name :
32 class Contact < ActiveRecord::Base
33 order_by "contacts.first_name, contacts.last_name"