我正在尝试在我的 rails 4 应用程序中使用 money-rails gem。
我有一个参与者模型,其中包含每种货币和参与成本的属性。我的目标是让用户为每个实例指定一种货币,以及参与成本的金额。
在我的参与者模型中,我有:
货币化:participation_cost,with_model_currency: :amount_currency
在我的表格中,我要求用户选择一种货币并指定如下金额:
<%= f.input :participation_cost, label: 'What amount will you pay for participation costs?', :label_html => { :class => 'question-participants' }, placeholder: 'Whole numbers only', :input_html => {:style=> 'width: 250px; margin-top: 20px', class: 'response-participants'} %>
<br><br>
<%= f.input :currency, label: 'Select your costs currency', label_html: {class: 'fundingspace'}, collection: ["AUD Australian Dollars", "GBP British Pounds", "USD US Dollars" ], prompt: "Choose one" %> </div> <br>
在我看来,我想显示货币和金额。我目前有一个字符串如下:
<%= "#{@project.scope.try(:participant).try(:participation_cost)} #{@project.scope.try(:participant).try(:currency)}" %>
当我对此进行测试时,我只得到了参与成本的数字。我不明白货币。
在我的 money.rb 初始化程序中,我有:
config.default_currency = :gbp
任何人都可以帮忙吗?我不知道如何使用这个宝石。我已经按照用户指南进行操作,但它只能设置模型,例如基于实例的货币选择。有没有人成功地将它用于此目的?
谢谢