Skip to content

Instantly share code, notes, and snippets.

@mariorcardoso
Last active June 25, 2017 16:11
Show Gist options
  • Save mariorcardoso/e1241b6f154d22ff6f7b0054da5e69f9 to your computer and use it in GitHub Desktop.
Save mariorcardoso/e1241b6f154d22ff6f7b0054da5e69f9 to your computer and use it in GitHub Desktop.
class Product < ActiveRecord::Base
def cost
Money.new(cents, currency)
end
def cost=(cost)
self.cents = cost.cents
self.currency = cost.currency.to_s
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment