File tree Expand file tree Collapse file tree 1 file changed +1
-10
lines changed
lib/money-rails/active_model Expand file tree Collapse file tree 1 file changed +1
-10
lines changed Original file line number Diff line number Diff line change @@ -12,20 +12,11 @@ def decimal_pieces
1212 end
1313
1414 def validate_each ( record , attr , _value )
15- subunit_attr = record . class . monetized_attributes [ attr . to_s ]
1615 currency = record . public_send ( "currency_for_#{ attr } " )
1716
1817 # WARNING: Currently this is only defined in ActiveRecord extension!
1918 before_type_cast = :"#{ attr } _money_before_type_cast"
20- raw_value = record . try ( before_type_cast )
21-
22- # If raw value is nil and changed subunit is nil, then
23- # nil is a assigned value, else we should treat the
24- # subunit value as the one assigned.
25- if raw_value . nil? && record . public_send ( subunit_attr )
26- subunit_value = record . public_send ( subunit_attr )
27- raw_value = subunit_value . to_f / currency . subunit_to_unit
28- end
19+ raw_value = record . try ( before_type_cast ) || record . public_send ( attr )
2920
3021 return if options [ :allow_nil ] && raw_value . nil?
3122
You can’t perform that action at this time.
0 commit comments