Currency column type
sunblaze opened this issue · 0 comments
sunblaze commented
A currency column type would be very useful to have in this gem. Here's what I've used in the core to get what I was looking for.
class CurrencyType < ActiveRecord::Type::String
def serialize(value)
return value.iso_code if value.respond_to?(:iso_code)
super
end
def cast(value)
Money::Currency.new(value)
end
end
attribute :base, CurrencyType.new
attribute :counter, CurrencyType.new
Would be nice if the gem also registered the type so it could just be attribute :base, :currency