File tree 1 file changed +1
-10
lines changed
lib/money-rails/active_model
1 file changed +1
-10
lines changed Original file line number Diff line number Diff line change @@ -12,20 +12,11 @@ def decimal_pieces
12
12
end
13
13
14
14
def validate_each ( record , attr , _value )
15
- subunit_attr = record . class . monetized_attributes [ attr . to_s ]
16
15
currency = record . public_send ( "currency_for_#{ attr } " )
17
16
18
17
# WARNING: Currently this is only defined in ActiveRecord extension!
19
18
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 )
29
20
30
21
return if options [ :allow_nil ] && raw_value . nil?
31
22
You can’t perform that action at this time.
0 commit comments