aboutsummaryrefslogtreecommitdiffstats
path: root/activemodel/lib/active_model
diff options
context:
space:
mode:
authorEdouard CHIN <edouard.chin@shopify.com>2019-07-09 16:14:56 +0200
committerEdouard CHIN <edouard.chin@shopify.com>2019-07-10 18:40:12 +0200
commit07ff343857699f0806294539947cf485ff205a2b (patch)
treebf213ae34ba6e5d1cfd3d9d79969d796fc86c8af /activemodel/lib/active_model
parent84ff4f6ea2a118b47160e3fe7ed29bff52c2a7a2 (diff)
downloadrails-07ff343857699f0806294539947cf485ff205a2b.tar.gz
rails-07ff343857699f0806294539947cf485ff205a2b.tar.bz2
rails-07ff343857699f0806294539947cf485ff205a2b.zip
Fix errors getting duplicated when passed validations options:
- In 86620cc3aa8e2630bc8d934b1a86453276b9eee9, a change was made on how we remove error duplication on a record for autosave association This fix has one caveat where validation having a `if` / `unless` options passed as a proc would be considered different. Example: ```ruby class Book < ApplicationRecord has_one :author validates :title, presence: true, if -> { true } validates :title, presence: true, if -> { true } end Book.new.valid? # false Book.errors.full_messages # ["title can't be blank", "title can't be blank"] ``` While this example might sound strange, I think it's better to ignore `AM::Validations` options (if, unless ...) when making the comparison.
Diffstat (limited to 'activemodel/lib/active_model')
-rw-r--r--activemodel/lib/active_model/error.rb2
1 files changed, 1 insertions, 1 deletions
diff --git a/activemodel/lib/active_model/error.rb b/activemodel/lib/active_model/error.rb
index f7267fc7bf..5141bc6789 100644
--- a/activemodel/lib/active_model/error.rb
+++ b/activemodel/lib/active_model/error.rb
@@ -74,7 +74,7 @@ module ActiveModel
protected
def attributes_for_hash
- [@base, @attribute, @raw_type, @options]
+ [@base, @attribute, @raw_type, @options.except(*CALLBACKS_OPTIONS)]
end
end
end