Skip to content

Commit

Permalink
Change money-rails so that it is able to accept a lambda as default_c…
Browse files Browse the repository at this point in the history
…urrency
  • Loading branch information
Nerian committed Jun 24, 2014
1 parent e89e296 commit 6c62e0c
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 3 deletions.
1 change: 1 addition & 0 deletions CONTRIBUTORS
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ Felipe Rodrigues
Fotos Georgiadis
François KLINGLER
Garrett Lancaster
Gonzalo Rodríguez-Baltanás Díaz
Graham Pengelly
Hosam Aly
Jacob Vosmaer
Expand Down
2 changes: 1 addition & 1 deletion lib/money-rails/active_record/monetizable.rb
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ def monetized_attributes
send("#{instance_currency_name}=", money_currency.try(:iso_code))
else
current_currency = send("currency_for_#{name}")
if money_currency && current_currency != money_currency
if money_currency && current_currency != money_currency.id
raise "Can't change readonly currency '#{current_currency}' to '#{money_currency}' for field '#{name}'"
end
end
Expand Down
4 changes: 2 additions & 2 deletions lib/money-rails/configuration.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,12 @@ def configure
# Configuration parameters

def default_currency
Money.default_currency
Money::Currency.new(Money.default_currency)
end

# Set default currency of money library
def default_currency=(currency_name)
Money.default_currency = Money::Currency.new(currency_name)
Money.default_currency = currency_name
set_amount_column_for_default_currency!
set_currency_column_for_default_currency!
end
Expand Down

0 comments on commit 6c62e0c

Please sign in to comment.