ruby-on-rails – Money-Rails Gem – 实例货币
发布时间:2020-12-16 23:06:51 所属栏目:百科 来源:网络整理
导读:我在我的rails 4应用程序中有一个模型称为资金. 我正在使用Money Rails来处理货币/货币组件 – https://github.com/RubyMoney/money-rails 我的资金模型有3个资金属性叫做amount_expenses,amount_honorarium和amount_principal_financing. 资金模型还具有用
我在我的rails 4应用程序中有一个模型称为资金.
我正在使用Money Rails来处理货币/货币组件 – https://github.com/RubyMoney/money-rails 我的资金模型有3个资金属性叫做amount_expenses,amount_honorarium和amount_principal_financing. 资金模型还具有用于创建实例的用户的货币属性,以选择应该为三个资金属性中的每一个使用哪种货币. 当我运行迁移到add_monetize到三个资金属性中的每一个时,它创建了三个相应的货币属性. 我需要它们吗?我可以要求用户为每个实例选择一次货币,然后使用该货币保存三个供资属性吗?那会怎么样?如果我在资金表中只有一个货币属性,那么货币化是否会知道如何选择显示三种融资金额? 资金表有: t.boolean "expenses" t.boolean "honorarium" t.boolean "financing" t.string "currency" t.string "size" t.integer "amount_expenses" t.integer "amount_honorarium" t.integer "amount_principal_financing" t.float "return_on_finance" t.integer "period_of_return" t.text "expense_description" t.integer "scope_id" t.integer "amount_expenses_pennies",default: 0,null: false t.string "amount_expenses_currency",default: "GBP",null: false t.integer "amount_honorarium_pennies",null: false t.string "amount_honorarium_currency",null: false t.integer "amount_principal_financing_pennies",null: false t.string "amount_principal_financing_currency",null: false 结束 谢谢 解决方法
对于你们三个领域,你可以简单地写
monetize :field1,:field2,:field3,with_model_currency: :currency_field 在这种情况下,只有一个货币列就足够了. (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |
相关内容
- Qt模块化笔记之core——QXmlStreamWriter写XML
- C类型比较:typeid vs double dispatch dynamic_cast
- 详解UML中的6大关系(关联、依赖、聚合、组合、泛化、实现)
- ruby-on-rails – 如何在Rails中将服务目录添加到加载路径?
- 传递给const引用的C literal导致自动构造
- sqlite3 – 在SQLite中有一个布尔文本吗?
- 大数据学习——你知道Apache Cassandra 的优点有哪些吗?
- XML 头声明和standalone="yes"属性介绍
- C#获取一个指定范围内的随机日期函数代码
- ios – Swift 3:无法通过BLE连接到外设