diff options
author | Santiago Pastorino <santiago@wyeworks.com> | 2011-03-17 23:17:20 -0300 |
---|---|---|
committer | Santiago Pastorino <santiago@wyeworks.com> | 2011-03-17 23:17:20 -0300 |
commit | 445241d713782262134ede64a967369f803076ff (patch) | |
tree | 2a56fe2412d0179c3b9561c7c5eb8b7d9ae77647 /activemodel/lib | |
parent | 4532b39f5faa15af957e3b41b671f07ed201488d (diff) | |
download | rails-445241d713782262134ede64a967369f803076ff.tar.gz rails-445241d713782262134ede64a967369f803076ff.tar.bz2 rails-445241d713782262134ede64a967369f803076ff.zip |
define_attr_method should be able to define methods that returns nil
Diffstat (limited to 'activemodel/lib')
-rw-r--r-- | activemodel/lib/active_model/attribute_methods.rb | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/activemodel/lib/active_model/attribute_methods.rb b/activemodel/lib/active_model/attribute_methods.rb index 76bfd4b77d..73468afe55 100644 --- a/activemodel/lib/active_model/attribute_methods.rb +++ b/activemodel/lib/active_model/attribute_methods.rb @@ -106,8 +106,8 @@ module ActiveModel if block_given? sing.send :define_method, name, &block else - value = value.nil? ? 'nil' : value.to_s - sing.send(:define_method, name) { value.dup } + value = value.to_s if value + sing.send(:define_method, name) { value && value.dup } end end |