Closed brian-vogogo closed 8 years ago
Figured out a solution.
Added this in an initializer:
# Allow filters on money columns stored in cents.
# Converts a user-entered filter of "20.00" into a SQL query for 2000 cents.
#
def define_conditions_generator_column_money
Class.new(Wice::Columns::ConditionsGeneratorColumnInteger) {
def get_op_and_value(val)
op, num = super
num = (num * 100.0).round.to_i if num
return op, num
end
}
end
and in the Wice config:
Wice::Defaults::ADDITIONAL_COLUMN_PROCESSORS = {
:money => ['Wice::Columns::ViewColumnFloat', 'define_conditions_generator_column_money']
}
Goal:
but the Wice class is not loaded until later. It feels like I need to define my new class in the middle of load_column_processors in lib/wice/column.rb:9
Any options besides copying the source of the filter?