aboutsummaryrefslogtreecommitdiffstats
path: root/activemodel/lib/active_model/errors.rb
diff options
context:
space:
mode:
authorPiotr Sarnacki <drogus@gmail.com>2012-01-16 23:30:18 -0800
committerPiotr Sarnacki <drogus@gmail.com>2012-01-16 23:30:18 -0800
commita200446c5311477a17f6ff96c32215c72690f8b7 (patch)
treeb454a0bf82da1f74c44dadbed1f2acb18889dcaf /activemodel/lib/active_model/errors.rb
parent21afd9b96d70d1e2b1cffdfb60f7ec64ab240472 (diff)
parent6174d3ba244c448bf31b4a84aa45ac651bb9435c (diff)
downloadrails-a200446c5311477a17f6ff96c32215c72690f8b7.tar.gz
rails-a200446c5311477a17f6ff96c32215c72690f8b7.tar.bz2
rails-a200446c5311477a17f6ff96c32215c72690f8b7.zip
Merge pull request #4491 from pkondzior/master
Wrong behavior of ActiveModel::Errors#dup is causing regressions on Rails master
Diffstat (limited to 'activemodel/lib/active_model/errors.rb')
-rw-r--r--activemodel/lib/active_model/errors.rb7
1 files changed, 6 insertions, 1 deletions
diff --git a/activemodel/lib/active_model/errors.rb b/activemodel/lib/active_model/errors.rb
index c6535082d3..5cd8f77f0d 100644
--- a/activemodel/lib/active_model/errors.rb
+++ b/activemodel/lib/active_model/errors.rb
@@ -78,6 +78,11 @@ module ActiveModel
@messages = ActiveSupport::OrderedHash.new
end
+ def initialize_dup(other)
+ @messages = other.messages.dup
+ super
+ end
+
# Clear the messages
def clear
messages.clear
@@ -118,7 +123,7 @@ module ActiveModel
# p.errors[:name] = "must be set"
# p.errors[:name] # => ['must be set']
def []=(attribute, error)
- self[attribute.to_sym] << error
+ self[attribute] << error
end
# Iterates through each error key, value pair in the error messages hash.