Questions tagged [money-rails]

money-rails provides integration of the money gem with Ruby on Rails.

money-rails provides integration of the money gem with Ruby on Rails.

Both ActiveRecord and Mongoid are now supported.

For more information: https://github.com/RubyMoney/money-rails

86 questions
3
votes
2 answers

Money Rails Gem - null values

I have monetised two models of my Rails 4 app with Money-Rails gem. One is called Participants, the other is called Funding. Each of these models is nested inside another model, called Scope. Scope belongs to Project. The associations are: Project…
Mel
  • 2,481
  • 26
  • 113
  • 273
3
votes
1 answer

Using Money-Rails Gem for Multiple Currencies [Rails 4]

I have a Rails 4 app using the money-rails gem to define money objects. I have a money object called default_price_cents and a currency column on the User model to define currencies for each individual user (as seen here): class AddDefaultsToUser <…
zenben1126
  • 685
  • 1
  • 7
  • 25
2
votes
1 answer

How to configure money-rails gem to work with higher precision than 4 digits

We are using money-rails gem in our application. Until now, we were OK with 4 decimal digits precision, but we need to switch to 6. Unfortunately I'm unable to store higher precision numbers into Postgres - number is rounded before saving. class…
Adam Tomeček
  • 199
  • 1
  • 15
2
votes
1 answer

Money-rails gem - how to overide default currency and show decimal points

I'm using the rails-money gem for the first time for an events app I'm building. I have an events model which has a 'price' column with type integer. I want the user to be able to type in whatever variation they want (within reason) for the cost of…
Mike.Whitehead
  • 798
  • 18
  • 52
2
votes
1 answer

Rails money-rails: Is it necessary the monetize model definition if using migration?

Im a little bit confused with the documentation of money-rails, they say that if you have an integer column called "price_cents" you just need to add the monetize :price_cents definition in the model, however they also say that you can add the money…
svelandiag
  • 4,231
  • 1
  • 36
  • 72
2
votes
1 answer

Unknown attribute when monetizing a field using money-rails

I have the following class and I want to monetize a couple of its fields using the money-rails gem. class LineItem < ActiveRecord::Base monetize :unit_price_cents monetize :total_cents end This is how the schema looks: create_table…
8vius
  • 5,786
  • 14
  • 74
  • 136
2
votes
2 answers

Entering in large dollar values into rails money object

I have built an application running rails 4.1 and ruby 1.9.3 that uses the money-rails gem. I'm encountering an issue when I input large dollar values into form fields and save them to my PG database. The error is the…
Questifer
  • 1,113
  • 3
  • 18
  • 48
2
votes
1 answer

Validations on money-rails gem

I have money-rails gem installed and it's working flawlessly. However, there are no validations on money objects when I create a new model record. If I try to input letters into the money field, the form submission is successful, it just sets the…
zenben1126
  • 685
  • 1
  • 7
  • 25
2
votes
1 answer

Issue Performing Mathematical Operations on Money Objects - "Unknown Method "exchange_to" for 0:fixnum" [Rails 4] [Money Gem]

I currently have the money gem installed via money-rails and it's working great. I have a monetized object called :default_price and :default_price_cents and am using a :currency column to define the currencies. I also have a :default_packs column…
zenben1126
  • 685
  • 1
  • 7
  • 25
2
votes
1 answer

Auto parse price with money-rails

I have implemented the money-rails gem to enables prices on an Item model. Right now I parse a string with the price before creating a new Item in the items_controller.rb, like this: @item = Item.find_or_create_by_link!(params[:item][:link]) do |c| …
Daniel Friis
  • 444
  • 3
  • 23
1
vote
1 answer

Money-rails Gem currency symbol overlapping issue on some devices

I'm using money-rails latest version. The humanized_money_with_symbol helper currency symbol overlaps with the value like shown in the image below: Code - p = humanized_money_with_symbol product.price This works properly on the latest devices like…
Karan
  • 445
  • 5
  • 15
1
vote
0 answers

How do I lazy-load a config from an initializer?

I'm using Rails 6 with the 'money-rails' gem (for multiple currencies) and 'apartment' gem (for multi-tenancy). In the 'money-rails' documentation it is said that I could lazy-load the configuration of the default currency of the app, by using doing…
1
vote
1 answer

where to set locale_backend to comply with new changes in money-rails?

The money-rails gem will throw the following warning [DEPRECATION] You are using the default localization behaviour that will change in the next major release. Find out more - https://github.com/RubyMoney/money#deprecation The documentation says…
hellion
  • 4,602
  • 6
  • 38
  • 77
1
vote
2 answers

Money-Rails is discarding price amount after decimal point

I am building and Rails 5 API where I am trying to send money amount and store it in PostgresQL database. I am sending amount 2.4 but I see in database only 2 is stored. what I am doing wrong? my migration: class CreateTransactions <…
naqib83
  • 128
  • 3
  • 14
1
vote
1 answer

money-rails gem column naming conventions

I have an Order model with unit_price, discount_price, final_price etc.. All are integer fields in postgres db. Currently its rounding amount to the next integer and saves that. But now I found that this is not a good approach as it might cause some…
Abhilash
  • 2,864
  • 3
  • 33
  • 67