aboutsummaryrefslogtreecommitdiffstats
path: root/activemodel/lib/active_model/gem_version.rb
diff options
context:
space:
mode:
authorEdouard CHIN <edouard.chin@shopify.com>2019-07-10 17:52:43 +0200
committerEdouard CHIN <edouard.chin@shopify.com>2019-07-10 23:33:32 +0200
commit06756290d5000034e6815f57d5003111ff0b2865 (patch)
tree21d9459ff213c4416edc39c5430599d6478b6300 /activemodel/lib/active_model/gem_version.rb
parent84ff4f6ea2a118b47160e3fe7ed29bff52c2a7a2 (diff)
downloadrails-06756290d5000034e6815f57d5003111ff0b2865.tar.gz
rails-06756290d5000034e6815f57d5003111ff0b2865.tar.bz2
rails-06756290d5000034e6815f57d5003111ff0b2865.zip
Fix `AM::Errors.added?` trying to generate a message:
- When a ActiveRecord record get saved and validated as part of a collection association, the errors attribute are changed to reflect the children names. You end up with an error attribute that will look like this: `author.errors # {:'books.title' => [:blank]}` https://github.com/rails/rails/blob/2fe20cb55c76e6e50ec3a4ec5b03bbb65adba290/activerecord/lib/active_record/autosave_association.rb#L331-L340 We then can't check if the `books.title` errors was added using `ActiveModel::Errors#added?` because it tries to generate a message to make the match and end up calling the "books.title" method on the Author. ``` author.errors.added?(:'books.title', :blank) => NoMethodError: undefined method `books.title' ``` This patch modify the behaviour of `strict_match?` to not generate a message to make the comparison but instead make a strict comparison with the `options` from the error.
Diffstat (limited to 'activemodel/lib/active_model/gem_version.rb')
0 files changed, 0 insertions, 0 deletions