I have the following class and I want to monetize
a couple of its fields using the money-rails
gem.
class LineItem < ActiveRecord::Base
monetize :unit_price_cents
monetize :total_cents
end
This is how the schema looks:
create_table "line_items", force: :cascade do |t|
t.integer "invoice_id"
t.float "quantity"
t.string "unit_type"
t.string "description"
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.integer "unit_price_cents", null: false
t.integer "total_cents", null: false
end
For some reason I get undefined method 'unit_price' for #<LineItem:0x007ffb7881eb80>
unless I add aliasing to the monetized fields:
monetize :unit_price_cents, as: :unit_price