From 04adb690d986669f7a5871094ea40443f23dd045 Mon Sep 17 00:00:00 2001 From: Neeraj Singh Date: Mon, 14 Jun 2010 18:54:57 -0400 Subject: [PATCH] work in progress fix for #4653. Once it is tested out I will try to improvise code and will add a few lines to say what I am doing --- activemodel/lib/active_model/validations.rb | 5 +++++ 1 files changed, 5 insertions(+), 0 deletions(-) diff --git a/activemodel/lib/active_model/validations.rb b/activemodel/lib/active_model/validations.rb index d7e3544..8ceac00 100644 --- a/activemodel/lib/active_model/validations.rb +++ b/activemodel/lib/active_model/validations.rb @@ -124,6 +124,11 @@ module ActiveModel options[:if] = Array.wrap(options[:if]) options[:if] << "validation_context == :#{options[:on]}" end + first = args.first + if first && first.to_s == 'before' + options.is_a?(Hash) ? (options[:prepend] = true) : args.<<({:prepend => true}) + end + set_callback(:validate, *args, &block) end -- 1.6.5.2