diff options
author | Aditya Sanghi <asanghi@me.com> | 2011-04-29 02:54:37 +0530 |
---|---|---|
committer | Aditya Sanghi <asanghi@me.com> | 2011-04-29 02:54:37 +0530 |
commit | bf5cf5db86fa0aeb818d32541a35310de992f426 (patch) | |
tree | b5a1f7f1fb2cbc660b924faa8272a6fb4a06a5a7 /activemodel/lib | |
parent | e59491355e921c2275980fba5a85dfc8b5ed25f7 (diff) | |
download | rails-bf5cf5db86fa0aeb818d32541a35310de992f426.tar.gz rails-bf5cf5db86fa0aeb818d32541a35310de992f426.tar.bz2 rails-bf5cf5db86fa0aeb818d32541a35310de992f426.zip |
:if should not fire on validations when not in context with :on
Diffstat (limited to 'activemodel/lib')
-rw-r--r-- | activemodel/lib/active_model/validations.rb | 2 | ||||
-rw-r--r-- | activemodel/lib/active_model/validations/callbacks.rb | 4 |
2 files changed, 3 insertions, 3 deletions
diff --git a/activemodel/lib/active_model/validations.rb b/activemodel/lib/active_model/validations.rb index d968609e67..5e567307f3 100644 --- a/activemodel/lib/active_model/validations.rb +++ b/activemodel/lib/active_model/validations.rb @@ -133,7 +133,7 @@ module ActiveModel if options.key?(:on) options = options.dup options[:if] = Array.wrap(options[:if]) - options[:if] << "validation_context == :#{options[:on]}" + options[:if].unshift("validation_context == :#{options[:on]}") end args << options set_callback(:validate, *args, &block) diff --git a/activemodel/lib/active_model/validations/callbacks.rb b/activemodel/lib/active_model/validations/callbacks.rb index adc2867ad0..f187d6f378 100644 --- a/activemodel/lib/active_model/validations/callbacks.rb +++ b/activemodel/lib/active_model/validations/callbacks.rb @@ -31,7 +31,7 @@ module ActiveModel options = args.last if options.is_a?(Hash) && options[:on] options[:if] = Array.wrap(options[:if]) - options[:if] << "self.validation_context == :#{options[:on]}" + options[:if].unshift("self.validation_context == :#{options[:on]}") end set_callback(:validation, :before, *args, &block) end @@ -41,7 +41,7 @@ module ActiveModel options[:prepend] = true options[:if] = Array.wrap(options[:if]) options[:if] << "!halted" - options[:if] << "self.validation_context == :#{options[:on]}" if options[:on] + options[:if].unsfhit("self.validation_context == :#{options[:on]}") if options[:on] set_callback(:validation, :after, *(args << options), &block) end end |