Module OrderByModule
In: lib/modules/order_by_module.rb

Methods

Public Instance methods

Adds the order_by methods on the fly

[Source]

    # File lib/modules/order_by_module.rb, line 17
17:   def method_missing(method_id, *arguments)
18:     if match = /order_by_([_a-zA-Z]+)/.match(method_id.to_s)
19:       eval_str =
20:       'def ' + match[0] + '(options) ;' +
21:         'return find(:all, options.merge!(:order => "' + match[1] + ' DESC"));' +
22:       'end'
23:       eval eval_str
24:       return self.send(method_id, *arguments)
25:     else
26:       super
27:     end
28:   end

[Validate]