diff --git a/README.md b/README.md index 75f549cfc..a5ff20af5 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ # RubyMoney - Money-Rails [![Gem Version](https://badge.fury.io/rb/money-rails.svg)](http://badge.fury.io/rb/money-rails) -[![Build Status](https://secure.travis-ci.org/RubyMoney/money-rails.svg?branch=master)](http://travis-ci.org/RubyMoney/money-rails) +[![Ruby](https://github.com/RubyMoney/money-rails/actions/workflows/ruby.yml/badge.svg)](https://github.com/RubyMoney/money-rails/actions/workflows/ruby.yml) [![License](http://img.shields.io/:license-mit-green.svg?style=flat)](http://opensource.org/licenses/MIT) ## Introduction @@ -474,6 +474,12 @@ MoneyRails.configure do |config| # symbol: nil, # sign_before_symbol: nil # } + + # Set whether an error should be raised when parsing money values + # This includes assigning to a monetized field with the wrong currency + # Default value is false + # + # config.raise_error_on_money_parsing = true end ``` @@ -493,6 +499,7 @@ end * `amount_column`: Provide values for the amount column (holding the fractional part of a money object). * `currency_column`: Provide default values or even disable (`present: false`) the currency column. * `rounding_mode`: Set `Money.rounding_mode` to one of the BigDecimal constants. +* `raise_error_on_money_parsing`: Set whether errors should be raised when parsing money values ### Helpers diff --git a/lib/money-rails/active_record/monetizable.rb b/lib/money-rails/active_record/monetizable.rb index 35aa2eaba..4b6b5febf 100644 --- a/lib/money-rails/active_record/monetizable.rb +++ b/lib/money-rails/active_record/monetizable.rb @@ -10,7 +10,7 @@ class ReadOnlyCurrencyException < MoneyRails::Error; end module ClassMethods def monetized_attributes - monetized_attributes = @monetized_attributes || {} + monetized_attributes = @monetized_attributes || {}.with_indifferent_access if superclass.respond_to?(:monetized_attributes) monetized_attributes.merge(superclass.monetized_attributes) diff --git a/money-rails.gemspec b/money-rails.gemspec index bd73c2d86..4d0a05eed 100644 --- a/money-rails.gemspec +++ b/money-rails.gemspec @@ -42,5 +42,6 @@ Gem::Specification.new do |s| s.metadata['changelog_uri'] = 'https://github.com/RubyMoney/money-rails/blob/master/CHANGELOG.md' s.metadata['source_code_uri'] = 'https://github.com/RubyMoney/money-rails/' s.metadata['bug_tracker_uri'] = 'https://github.com/RubyMoney/money-rails/issues' + s.metadata['rubygems_mfa_required'] = 'true' end end