You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
jcfischer edited this page Nov 30, 2012
·
14 revisions
Define accessor methods to let Active Record deal with embedding the money object in your models. The following example assumes a `price_cents` and a `price_currency` field.
defpriceMoney.newprice_cents,price_currencyenddefprice=(value)value=Money.parse(value)ifvalue.instance_of?String# otherwise assume, that value is a Money objectwrite_attribute:price_cents,value.centswrite_attribute:price_currency,value.currency_as_stringend
With the example above, your migration should include the following lines: