18
19
20
21
22
23
24
|
# File 'lib/numeric_scopes.rb', line 18
def create_numeric_scopes_for_column(name)
scope :"#{name}_to", lambda { |value| where("#{quoted_table_name}.#{name} <= ?", value) }
scope :"#{name}_from", lambda { |value| where("#{quoted_table_name}.#{name} >= ?", value) }
scope :"#{name}_above", lambda { |value| where("#{quoted_table_name}.#{name} > ?", value) }
scope :"#{name}_below", lambda { |value| where("#{quoted_table_name}.#{name} < ?", value) }
scope :"#{name}_between", lambda { |from, to| where("#{quoted_table_name}.#{name} BETWEEN ? AND ?", from, to) }
end
|