diff options
author | David Heinemeier Hansson <david@loudthinking.com> | 2006-09-05 18:48:10 +0000 |
---|---|---|
committer | David Heinemeier Hansson <david@loudthinking.com> | 2006-09-05 18:48:10 +0000 |
commit | 9d7e6432b22a11e96ad7a3cab7510fac7b3927d6 (patch) | |
tree | e2d4d84550401d00a6e0dbe0b38fc6ae475803f5 /activerecord/lib/active_record/validations.rb | |
parent | d48322ecca83765a47c054aa72a7165efe9a81f5 (diff) | |
download | rails-9d7e6432b22a11e96ad7a3cab7510fac7b3927d6.tar.gz rails-9d7e6432b22a11e96ad7a3cab7510fac7b3927d6.tar.bz2 rails-9d7e6432b22a11e96ad7a3cab7510fac7b3927d6.zip |
Deprecated ActiveRecord::Base.new_record? in favor of ActiveRecord::Base.new? (old version still works until Rails 2.0) [DHH]
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@5017 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'activerecord/lib/active_record/validations.rb')
-rwxr-xr-x | activerecord/lib/active_record/validations.rb | 11 |
1 files changed, 3 insertions, 8 deletions
diff --git a/activerecord/lib/active_record/validations.rb b/activerecord/lib/active_record/validations.rb index c9d4740670..cc372b5042 100755 --- a/activerecord/lib/active_record/validations.rb +++ b/activerecord/lib/active_record/validations.rb @@ -333,8 +333,7 @@ module ActiveRecord attr_accessor *(attr_names.map { |n| "#{n}_confirmation" }) validates_each(attr_names, configuration) do |record, attr_name, value| - confirm = record.send("#{attr_name}_confirmation") - record.errors.add(attr_name, configuration[:message]) unless value.nil? || value == confirm + record.errors.add(attr_name, configuration[:message]) unless record.send("#{attr_name}_confirmation").nil? or value == record.send("#{attr_name}_confirmation") end end @@ -375,10 +374,6 @@ module ActiveRecord # # The first_name attribute must be in the object and it cannot be blank. # - # If you want to validate the presence of a boolean field (where the real values are true and false), - # you will want to use validates_inclusion_of :field_name, :in => [true, false] - # This is due to the way Object#blank? handles boolean values. false.blank? # => true - # # Configuration options: # * <tt>message</tt> - A custom error message (default is: "can't be blank") # * <tt>on</tt> - Specifies when this validation is active (default is :save, other options :create, :update) @@ -543,7 +538,7 @@ module ActiveRecord condition_params << scope_value end end - unless record.new_record? + unless record.new? condition_sql << " AND #{record.class.table_name}.#{record.class.primary_key} <> ?" condition_params << record.send(:id) end @@ -777,7 +772,7 @@ module ActiveRecord run_validations(:validate) validate - if new_record? + if new? run_validations(:validate_on_create) validate_on_create else |