aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib
diff options
context:
space:
mode:
authorPratik Naik <pratiknaik@gmail.com>2009-03-21 01:11:38 +0000
committerPratik Naik <pratiknaik@gmail.com>2009-03-21 01:11:38 +0000
commit22ad30ed600a3304c749b0406325b3b43de3d607 (patch)
tree905cab2c383e73b3d22aa646ac1ad66ffca33a6f /activerecord/lib
parent6173e5bfaec44729ecabc2e6e05aa2608a85981f (diff)
downloadrails-22ad30ed600a3304c749b0406325b3b43de3d607.tar.gz
rails-22ad30ed600a3304c749b0406325b3b43de3d607.tar.bz2
rails-22ad30ed600a3304c749b0406325b3b43de3d607.zip
Move validate_on_create and validate_on_update from ActiveModel to ActiveRecord
Diffstat (limited to 'activerecord/lib')
-rw-r--r--activerecord/lib/active_record/validations.rb14
-rw-r--r--activerecord/lib/active_record/validations/associated.rb3
2 files changed, 13 insertions, 4 deletions
diff --git a/activerecord/lib/active_record/validations.rb b/activerecord/lib/active_record/validations.rb
index a9e6654aec..9a7b2a47bc 100644
--- a/activerecord/lib/active_record/validations.rb
+++ b/activerecord/lib/active_record/validations.rb
@@ -99,9 +99,8 @@ module ActiveRecord
module Validations
def self.included(base) # :nodoc:
- base.extend ClassMethods
-
base.send :include, ActiveModel::Validations
+ base.extend ClassMethods
base.send :include, InstanceMethods
base.define_callbacks :validate_on_create, :validate_on_update
@@ -125,6 +124,17 @@ module ActiveRecord
object
end
end
+
+ def validation_method(on)
+ case on
+ when :create
+ :validate_on_create
+ when :update
+ :validate_on_update
+ else
+ :validate
+ end
+ end
end
module InstanceMethods
diff --git a/activerecord/lib/active_record/validations/associated.rb b/activerecord/lib/active_record/validations/associated.rb
index 1d7df6b771..92f47d770f 100644
--- a/activerecord/lib/active_record/validations/associated.rb
+++ b/activerecord/lib/active_record/validations/associated.rb
@@ -33,8 +33,7 @@ module ActiveRecord
# 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_associated(*attr_names)
- configuration = { :on => :save }
- configuration.update(attr_names.extract_options!)
+ configuration = attr_names.extract_options!
validates_each(attr_names, configuration) do |record, attr_name, value|
unless (value.is_a?(Array) ? value : [value]).collect { |r| r.nil? || r.valid? }.all?