diff options
-rw-r--r-- | activemodel/lib/active_model/validations.rb | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/activemodel/lib/active_model/validations.rb b/activemodel/lib/active_model/validations.rb index 5a3225a7e6..be780d570b 100644 --- a/activemodel/lib/active_model/validations.rb +++ b/activemodel/lib/active_model/validations.rb @@ -195,12 +195,14 @@ module ActiveModel def validators_on(*attributes) options = attributes.extract_options! - attributes.map do |attribute| + validators = attributes.map do |attribute| _validators[attribute.to_sym] - end.flatten.tap do |validators| - if options[:kind] - validators.select! { |validator| validator.kind == options[:kind] } - end + end.flatten + + if options[:kind] + validators.select! { |validator| validator.kind == options[:kind] } + else + validators end end |