1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00
rails--rails/activemodel/lib
Edouard CHIN 06756290d5 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]}`

  2fe20cb55c/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.
2019-07-10 23:33:32 +02:00
..
active_model Fix AM::Errors.added? trying to generate a message: 2019-07-10 23:33:32 +02:00
active_model.rb Bump license years for 2019 2018-12-31 10:24:38 +07:00