diff options
author | Rafael França <rafaelmfranca@gmail.com> | 2018-11-13 11:11:21 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-11-13 11:11:21 -0500 |
commit | 24ffc15d4ec1a98bddf624e5995043b58712b07a (patch) | |
tree | 2e94488d5ad21a9c4b3a3a14b211e4f68f71cb4c /activemodel/lib/active_model | |
parent | 30857f9c8b671d71550ccd126fcbc9d548a22ff3 (diff) | |
parent | 13b77fa1cb49495f1da79fec6f06475d5dd29af7 (diff) | |
download | rails-24ffc15d4ec1a98bddf624e5995043b58712b07a.tar.gz rails-24ffc15d4ec1a98bddf624e5995043b58712b07a.tar.bz2 rails-24ffc15d4ec1a98bddf624e5995043b58712b07a.zip |
Merge pull request #34417 from r3trofitted/fix/added_options_check
Fix ignored options in the `#added?` method
Diffstat (limited to 'activemodel/lib/active_model')
-rw-r--r-- | activemodel/lib/active_model/errors.rb | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/activemodel/lib/active_model/errors.rb b/activemodel/lib/active_model/errors.rb index af94d52d45..9de6b609a3 100644 --- a/activemodel/lib/active_model/errors.rb +++ b/activemodel/lib/active_model/errors.rb @@ -327,11 +327,11 @@ module ActiveModel # person.errors.added? :name, :too_long # => false # person.errors.added? :name, "is too long" # => false def added?(attribute, message = :invalid, options = {}) + message = message.call if message.respond_to?(:call) + if message.is_a? Symbol - self.details[attribute.to_sym].map { |e| e[:error] }.include? message + details[attribute.to_sym].include? normalize_detail(message, options) else - message = message.call if message.respond_to?(:call) - message = normalize_message(attribute, message, options) self[attribute].include? message end end |