aboutsummaryrefslogtreecommitdiffstats
path: root/activemodel/lib
diff options
context:
space:
mode:
authorRafael Mendonça França <rafaelmfranca@gmail.com>2012-11-05 07:46:51 -0800
committerRafael Mendonça França <rafaelmfranca@gmail.com>2012-11-05 07:46:51 -0800
commitce9b6ad5ae8de8947bea8ba06dcad27e09a0dbac (patch)
treed364c9ed6d8095ebed3890f24d265201af06a559 /activemodel/lib
parentb8b100a83404e6d506dd806d0e11bade26f0d534 (diff)
parent70ecf6c518c7d33724559795fc77e4307ba4d501 (diff)
downloadrails-ce9b6ad5ae8de8947bea8ba06dcad27e09a0dbac.tar.gz
rails-ce9b6ad5ae8de8947bea8ba06dcad27e09a0dbac.tar.bz2
rails-ce9b6ad5ae8de8947bea8ba06dcad27e09a0dbac.zip
Merge pull request #8118 from nashby/activemodel-errors
use Array() instead of flatten
Diffstat (limited to 'activemodel/lib')
-rw-r--r--activemodel/lib/active_model/errors.rb4
1 files changed, 2 insertions, 2 deletions
diff --git a/activemodel/lib/active_model/errors.rb b/activemodel/lib/active_model/errors.rb
index 6882b59e26..c82d4f012c 100644
--- a/activemodel/lib/active_model/errors.rb
+++ b/activemodel/lib/active_model/errors.rb
@@ -308,7 +308,7 @@ module ActiveModel
# person.errors.messages
# # => {:name=>["can't be empty"]}
def add_on_empty(attributes, options = {})
- [attributes].flatten.each do |attribute|
+ Array(attributes).each do |attribute|
value = @base.send(:read_attribute_for_validation, attribute)
is_empty = value.respond_to?(:empty?) ? value.empty? : false
add(attribute, :empty, options) if value.nil? || is_empty
@@ -322,7 +322,7 @@ module ActiveModel
# person.errors.messages
# # => {:name=>["can't be blank"]}
def add_on_blank(attributes, options = {})
- [attributes].flatten.each do |attribute|
+ Array(attributes).each do |attribute|
value = @base.send(:read_attribute_for_validation, attribute)
add(attribute, :blank, options) if value.blank?
end