Module: Pacecar::Order::ClassMethods

Defined in:
lib/pacecar/order.rb

Instance Method Summary collapse

Instance Method Details

#define_order_scopesObject



13
14
15
16
17
18
19
20
# File 'lib/pacecar/order.rb', line 13

def define_order_scopes
  safe_column_names.each do |name|
    scope "by_#{name}", ->(*args) {
      direction = args.flatten.first || 'asc'
      order("#{name} #{direction}")
    }
  end
end