Can anybody share some examples of their Money implementation ?
I’m trying to setup a Model to use this library, but can’t seem to wrap
my
head around how it is exactly supposed to work.
My Model (Foo) looks like:
composed_of :commission, :class_name => “Money”, :mapping => [
%w(commission_cents cents), %w(commission_currency currency) ]
Yet, in script/console, I’m unable to get the correct behaviour (at
least I
think), from the library.
t = Foo.new(:commission => 34)
NoMethodError: undefined methodcents' for 34:Fixnum from (eval):3:in
commission=’
I’ve tried just playing with the Money object as well, but regardless of
what number I pass into the Money constructor, it always provides me
with
the exact number I specify as the “cents” value. So, If I do:
Money.new(
34.43)… it tells me that the instance has 34 cents.
I must be overlooking something. Any insight would be greatly
appreciated !