diff options
author | Rick Olson <technoweenie@gmail.com> | 2007-12-12 23:55:14 +0000 |
---|---|---|
committer | Rick Olson <technoweenie@gmail.com> | 2007-12-12 23:55:14 +0000 |
commit | d98728e09132cfceea89436eb1a120cbe5a2219d (patch) | |
tree | c98360b4f5165ae9d5f81fe8f075cdf08486684f /activerecord/lib | |
parent | 66e97c34c116bbf0e7b87802e81a9f7df0684b47 (diff) | |
download | rails-d98728e09132cfceea89436eb1a120cbe5a2219d.tar.gz rails-d98728e09132cfceea89436eb1a120cbe5a2219d.tar.bz2 rails-d98728e09132cfceea89436eb1a120cbe5a2219d.zip |
Fix that validates_acceptance_of still works for non-existent tables (useful for bootstrapping new databases). Closes #10474 [hasmanyjosh]
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@8377 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'activerecord/lib')
-rwxr-xr-x | activerecord/lib/active_record/validations.rb | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/activerecord/lib/active_record/validations.rb b/activerecord/lib/active_record/validations.rb index 1845f14116..8c9ff437d7 100755 --- a/activerecord/lib/active_record/validations.rb +++ b/activerecord/lib/active_record/validations.rb @@ -429,7 +429,7 @@ module ActiveRecord configuration = { :message => ActiveRecord::Errors.default_error_messages[:confirmation], :on => :save } configuration.update(attr_names.extract_options!) - attr_accessor *(attr_names.map { |n| "#{n}_confirmation" }) + attr_accessor(*(attr_names.map { |n| "#{n}_confirmation" })) validates_each(attr_names, configuration) do |record, attr_name, value| record.errors.add(attr_name, configuration[:message]) unless record.send("#{attr_name}_confirmation").nil? or value == record.send("#{attr_name}_confirmation") @@ -462,7 +462,13 @@ module ActiveRecord configuration = { :message => ActiveRecord::Errors.default_error_messages[:accepted], :on => :save, :allow_nil => true, :accept => "1" } configuration.update(attr_names.extract_options!) - attr_accessor *attr_names.reject { |name| column_names.include? name.to_s } + db_cols = begin + column_names + rescue ActiveRecord::StatementInvalid + [] + end + names = attr_names.reject { |name| db_cols.include?(name.to_s) } + attr_accessor(*names) validates_each(attr_names,configuration) do |record, attr_name, value| record.errors.add(attr_name, configuration[:message]) unless value == configuration[:accept] |