Default Order plugin

Plugin details

The default_order plugin provides a 'order_by' method to be called in your models.

Websitehttp://blog.gwikzone.org/pages/ruby_on_rails_default_order_plugin Repositoryhttp://svn.gwikzone.org/public/default_order Author Antonin AMAND Tags order LicenseUnknown

Documentation

Install the plugin:
ruby script/plugin install http://svn.gwikzone.org/public/default_order

example :

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.

example :

Contact.find(:all, :conditions => "last_name LIKE '%toto%'")
# will act as if you had written this
Contact.find(:all, :order => "last_name, first_name",
	:conditions => "last_name LIKE '%toto%'")
# but if you provide :order it will override the default order


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

Further Documentation

There is currently no advanced documentation for this plugin.

New documentation

Edit plugin | Back in time (2 older versions) | Last edited by: scott, about 1 year ago