kristianmandrup / money-mongoid

Standalone Mongoid support and integration for the Money gem
MIT License
9 stars 6 forks source link

Support editing the money field in forms. #9

Open vgchl opened 11 years ago

vgchl commented 11 years ago

The demongoize method only supports an initial value that is a hash. When submitting a form, this value is a string, causing TypeErrors.

Have a look at this class from money-rails, whose demongoize method is a bit more robust.

vgchl commented 11 years ago

FYI, my current fix is overriding the field setter:

def price=(price)
  price = price.to_money if price.respond_to? :to_money
  self[:price] = price
end
kristianmandrup commented 11 years ago

Could you post a pull request for these improvements? Thanks!

kristianmandrup commented 11 years ago

In the next release I would like to remove all Mongoid 2 support and improve the Mongoid 3+ support ;) You wanna help out?