我有以下课程,我想monetize
使用money-rails
gem 来处理它的几个字段。
class LineItem < ActiveRecord::Base
monetize :unit_price_cents
monetize :total_cents
end
这是架构的外观:
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
出于某种原因,undefined method 'unit_price' for #<LineItem:0x007ffb7881eb80>
除非我在货币化字段中添加别名,否则我会得到:
monetize :unit_price_cents, as: :unit_price