money-rails

How to prevent Ruby money floating point errors

微笑、不失礼 提交于 2019-12-11 03:36:58
问题 I'm using Rails with the money-rails gem to handle money columns. Is there any way to prevent floating point errors from occuring? (even a hack will do, I just want to make sure no such errors are presented to the end user) Rspec example case: it "correctly manipulates simple money calculations" do # Money.infinite_precision = false or true i've tried both start_val = Money.new("1000", "EUR") expect(start_val / 30 * 30).to eq start_val end Result Failure/Error: expect(start_val / 30 * 30).to

Money-Rails Gem and Instance Currencies

为君一笑 提交于 2019-12-08 10:42:22
问题 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

Money-Rails Gem with Rails 4 - Instance Currencies

你离开我真会死。 提交于 2019-12-06 05:52:43
问题 Im trying to use monetise in my Rails 4 app (with money-rails gem). How do you allow a user to submit a number dollars only? When I input 100 I get $1 instead of $100. In my model, I have: monetize :participation_cost_pennies, with_model_currency: :participation_cost_currency I am using instance currencies, so users select the relevant currency. My table has columns for participation cost, participation cost pennies and participation cost currency. In my form, I have: <%= par.select