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 < ActiveRecord::Migration
def change
add_money :users, :default_price
add_column :users, :currency, :string
end
end
My user.rb has the following lines:
register_currency :usd
monetize :default_price_cents, with_model_currency: :default_price_currency
Users then define their currency in registration (HAML):
.form-group
= f.label :currency
= f.select :default_price_currency, [['USD','usd'],['CAD','cad'],['DKK','dkk']]
I have tried to have this set with both :default_price_currency
as well as :currency
.
In my view, I have:
humanized_money_with_symbol @default_price
The Problem:
When this I display the default price in my view, it for some reason uses the currency I have defined with register_currency
in my model, instead of using the currency defined by the user upon registration. How do I get the app to refer to the user defined currency instead of the registered currency for that model?