aboutsummaryrefslogtreecommitdiffstats
path: root/activemodel/lib/active_model/validations/inclusion.rb
diff options
context:
space:
mode:
Diffstat (limited to 'activemodel/lib/active_model/validations/inclusion.rb')
-rw-r--r--activemodel/lib/active_model/validations/inclusion.rb7
1 files changed, 5 insertions, 2 deletions
diff --git a/activemodel/lib/active_model/validations/inclusion.rb b/activemodel/lib/active_model/validations/inclusion.rb
index 446646d247..049b093618 100644
--- a/activemodel/lib/active_model/validations/inclusion.rb
+++ b/activemodel/lib/active_model/validations/inclusion.rb
@@ -1,4 +1,6 @@
module ActiveModel
+
+ # == Active Model Inclusion Validator
module Validations
class InclusionValidator < EachValidator
def check_validity!
@@ -7,8 +9,9 @@ module ActiveModel
end
def validate_each(record, attribute, value)
- return if options[:in].include?(value)
- record.errors.add(attribute, :inclusion, :default => options[:message], :value => value)
+ unless options[:in].include?(value)
+ record.errors.add(attribute, :inclusion, options.except(:in).merge!(:value => value))
+ end
end
end