I am trying to use monetization in my Rails 4 application (with gems with money rails).
How do you allow a user to send only dollars? When I enter 100, I get $ 1 instead of $ 100.
In my model, I have:
monetize :participation_cost_pennies, with_model_currency: :participation_cost_currency
I use instance currency, so users select the appropriate currency. My table has columns for participation costs, quotes for participation costs and participation costs.
In my form, I have:
<%= par.select :participation_cost_currency, options_for_select(major_currencies(Money::Currency.table)), label: false, prompt: "Select your costs currency" %> <%= par.input :participation_cost, label: false, placeholder: 'Whole numbers only', :input_html => {:style => 'width: 250px; margin-top: 20px', class: 'response-project'} %>
In my opinion, I have:
<%= money_without_cents_and_with_symbol @project.scope.participant.participation_cost %>
Replacing the "participation cost quotes" with the participation cost in the form, I get the number for display as an integer without cents. Now I get $ 10,000 when I enter 100 (so the inverse problem is that it adds 2 00s to the end of my input.
ruby-on-rails money-rails
Mel
source share