Permalink
Browse files

Made has_details convert blank BigDecimal values to nil instead of 0.0

  • Loading branch information...
1 parent b7cdc51 commit 23d17fefd58ebd7705fa01b58c660c7308fb8821 @tarmo tarmo committed with erkki Jan 27, 2010
Showing with 1 addition and 1 deletion.
  1. +1 −1 lib/has_details.rb
View
@@ -52,7 +52,7 @@ def has_details(options = {})
elsif t == Integer
"val = (val.nil? ? nil : (Integer(val) rescue nil))"
elsif t == BigDecimal
- "val = val.is_a?(BigDecimal) ? val : val.to_d"
+ "val = val.is_a?(BigDecimal) ? val : (val.blank? ? nil : val.to_d)"
else
"raise \"Assigned value must be a #{t.inspect}\" unless val.nil? || val.is_a?(#{t.inspect})"
end

0 comments on commit 23d17fe

Please sign in to comment.