I am trying to use the money-rails gem in my rails 4 app.
I have a participant model which has attributes for each of currency and participation_cost in it. My objective is for users to specify a currency for each instance, and an amount of the cost of participation.
In my participant model, I have:
monetize :participation_cost, with_model_currency: :amount_currency
In my form, i ask users to select a currency and specify an amount as follows:
<%= 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>
In my view, I want to display the currency and the amount. I currently have a string as follows:
<%= "#{@project.scope.try(:participant).try(:participation_cost)} #{@project.scope.try(:participant).try(:currency)}" %>
When I test this, I only get the number that is the participation_cost. I don't get the currency.
In my money.rb initialiser, I have:
config.default_currency = :gbp
Can anyone help? I don't know how to use this gem. I've followed the user guide but it only gets as far as setting up the model for instance based currency selections. Has anyone successfully used it for this purpose?
Thank you