Why can't you do this (example from one of my applications):
composed_of :cents_cost_amount,
:class_name => "Money",
:mapping => [%w(cents_cost_amount cents), %w(currency currency_as_string)],
:constructor => Proc.new { |cents, currency| Money.new(cents || 0, currency || Money.default_currency) },
:converter => Proc.new { |value| value.respond_to?(:to_money) ? value.to_money : raise(ArgumentError, "Can't convert #{value.class} to Money") }
validates :cents_cost_amount,
:numericality => {:greater_than_or_equal_to => 0,
:less_than_or_equal_to => 1000000,
:message => "Only amounts in the range 0 to 10000.00 are allowed." }
It is difficult to give you more information about your problem without a specific example.
source
share