diff options
author | Jeremy Kemper <jeremy@bitsweat.net> | 2009-08-05 17:09:56 -0700 |
---|---|---|
committer | Jeremy Kemper <jeremy@bitsweat.net> | 2009-08-05 17:09:56 -0700 |
commit | 7f717abb0ed280ba1a1f8abfeeff84bf24cad3e7 (patch) | |
tree | 7f8ac20c20cae72f03afbcfe7f476f9776c60146 /activemodel/lib/active_model/errors.rb | |
parent | 230d43fbf5dee569ea031c8c394ba9ce70804cae (diff) | |
parent | 5ce3831faf684aea75948ce4602b6b9de361c11e (diff) | |
download | rails-7f717abb0ed280ba1a1f8abfeeff84bf24cad3e7.tar.gz rails-7f717abb0ed280ba1a1f8abfeeff84bf24cad3e7.tar.bz2 rails-7f717abb0ed280ba1a1f8abfeeff84bf24cad3e7.zip |
Merge branch 'master' of git@github.com:rails/rails
Diffstat (limited to 'activemodel/lib/active_model/errors.rb')
-rw-r--r-- | activemodel/lib/active_model/errors.rb | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/activemodel/lib/active_model/errors.rb b/activemodel/lib/active_model/errors.rb index a47d89ac0e..7a3001174f 100644 --- a/activemodel/lib/active_model/errors.rb +++ b/activemodel/lib/active_model/errors.rb @@ -68,7 +68,7 @@ module ActiveModel # Will add an error message to each of the attributes in +attributes+ that is empty. def add_on_empty(attributes, custom_message = nil) [attributes].flatten.each do |attribute| - value = @base.instance_eval { read_attribute_for_validation(attribute) } + value = @base.send(:read_attribute_for_validation, attribute) is_empty = value.respond_to?(:empty?) ? value.empty? : false add(attribute, :empty, :default => custom_message) unless !value.nil? && !is_empty end @@ -77,7 +77,7 @@ module ActiveModel # Will add an error message to each of the attributes in +attributes+ that is blank (using Object#blank?). def add_on_blank(attributes, custom_message = nil) [attributes].flatten.each do |attribute| - value = @base.instance_eval { read_attribute_for_validation(attribute) } + value = @base.send(:read_attribute_for_validation, attribute) add(attribute, :blank, :default => custom_message) if value.blank? end end @@ -146,7 +146,7 @@ module ActiveModel defaults = defaults.compact.flatten << :"messages.#{message}" key = defaults.shift - value = @base.instance_eval { read_attribute_for_validation(attribute) } + value = @base.send(:read_attribute_for_validation, attribute) options = { :default => defaults, :model => @base.class.name.humanize, |