diff options
Diffstat (limited to 'activemodel/lib/active_model/validations')
6 files changed, 6 insertions, 10 deletions
diff --git a/activemodel/lib/active_model/validations/acceptance.rb b/activemodel/lib/active_model/validations/acceptance.rb index db1fd04bb5..0c9ef51726 100644 --- a/activemodel/lib/active_model/validations/acceptance.rb +++ b/activemodel/lib/active_model/validations/acceptance.rb @@ -25,7 +25,7 @@ module ActiveModel # not occur (e.g. <tt>:unless => :skip_validation</tt>, or <tt>:unless => Proc.new { |user| user.signup_step <= 2 }</tt>). The # method, proc or string should return or evaluate to a true or false value. def validates_acceptance_of(*attr_names) - configuration = { :on => :save, :allow_nil => true, :accept => "1" } + configuration = { :allow_nil => true, :accept => "1" } configuration.update(attr_names.extract_options!) db_cols = begin diff --git a/activemodel/lib/active_model/validations/confirmation.rb b/activemodel/lib/active_model/validations/confirmation.rb index 5f18da58e3..b9823172f7 100644 --- a/activemodel/lib/active_model/validations/confirmation.rb +++ b/activemodel/lib/active_model/validations/confirmation.rb @@ -30,8 +30,7 @@ module ActiveModel # not occur (e.g. <tt>:unless => :skip_validation</tt>, or <tt>:unless => Proc.new { |user| user.signup_step <= 2 }</tt>). The # method, proc or string should return or evaluate to a true or false value. def validates_confirmation_of(*attr_names) - configuration = { :on => :save } - configuration.update(attr_names.extract_options!) + configuration = attr_names.extract_options! attr_accessor(*(attr_names.map { |n| "#{n}_confirmation" })) diff --git a/activemodel/lib/active_model/validations/exclusion.rb b/activemodel/lib/active_model/validations/exclusion.rb index 435ba5cab6..0aa9848ee1 100644 --- a/activemodel/lib/active_model/validations/exclusion.rb +++ b/activemodel/lib/active_model/validations/exclusion.rb @@ -21,8 +21,7 @@ module ActiveModel # not occur (e.g. <tt>:unless => :skip_validation</tt>, or <tt>:unless => Proc.new { |user| user.signup_step <= 2 }</tt>). The # method, proc or string should return or evaluate to a true or false value. def validates_exclusion_of(*attr_names) - configuration = { :on => :save } - configuration.update(attr_names.extract_options!) + configuration = attr_names.extract_options! enum = configuration[:in] || configuration[:within] diff --git a/activemodel/lib/active_model/validations/inclusion.rb b/activemodel/lib/active_model/validations/inclusion.rb index 0cb8e44770..a4bc8fe035 100644 --- a/activemodel/lib/active_model/validations/inclusion.rb +++ b/activemodel/lib/active_model/validations/inclusion.rb @@ -21,8 +21,7 @@ module ActiveModel # not occur (e.g. <tt>:unless => :skip_validation</tt>, or <tt>:unless => Proc.new { |user| user.signup_step <= 2 }</tt>). The # method, proc or string should return or evaluate to a true or false value. def validates_inclusion_of(*attr_names) - configuration = { :on => :save } - configuration.update(attr_names.extract_options!) + configuration = attr_names.extract_options! enum = configuration[:in] || configuration[:within] diff --git a/activemodel/lib/active_model/validations/numericality.rb b/activemodel/lib/active_model/validations/numericality.rb index 99035b8af8..79fca2f1ea 100644 --- a/activemodel/lib/active_model/validations/numericality.rb +++ b/activemodel/lib/active_model/validations/numericality.rb @@ -32,7 +32,7 @@ module ActiveModel # not occur (e.g. <tt>:unless => :skip_validation</tt>, or <tt>:unless => Proc.new { |user| user.signup_step <= 2 }</tt>). The # method, proc or string should return or evaluate to a true or false value. def validates_numericality_of(*attr_names) - configuration = { :on => :save, :only_integer => false, :allow_nil => false } + configuration = { :only_integer => false, :allow_nil => false } configuration.update(attr_names.extract_options!) numericality_options = ALL_NUMERICALITY_CHECKS.keys & configuration.keys diff --git a/activemodel/lib/active_model/validations/presence.rb b/activemodel/lib/active_model/validations/presence.rb index 4fd60621cd..518bc8a952 100644 --- a/activemodel/lib/active_model/validations/presence.rb +++ b/activemodel/lib/active_model/validations/presence.rb @@ -26,8 +26,7 @@ module ActiveModel # The method, proc or string should return or evaluate to a true or false value. # def validates_presence_of(*attr_names) - configuration = { :on => :save } - configuration.update(attr_names.extract_options!) + configuration = attr_names.extract_options! # can't use validates_each here, because it cannot cope with nonexistent attributes, # while errors.add_on_empty can |