Ruby on Rails | Screencasts | Download | Documentation | Weblog | Community | Source

Changeset 8377

Show
Ignore:
Timestamp:
12/12/07 23:55:14 (2 years ago)
Author:
rick
Message:

Fix that validates_acceptance_of still works for non-existent tables (useful for bootstrapping new databases). Closes #10474 [hasmanyjosh]

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/activerecord/CHANGELOG

    r8376 r8377  
    11*SVN* 
     2 
     3* Fix that validates_acceptance_of still works for non-existent tables (useful for bootstrapping new databases).  Closes #10474 [hasmanyjosh] 
    24 
    35* Ensure that the :uniq option for has_many :through associations retains the order.  #10463 [remvee] 
  • trunk/activerecord/lib/active_record/validations.rb

    r8345 r8377  
    430430        configuration.update(attr_names.extract_options!) 
    431431 
    432         attr_accessor *(attr_names.map { |n| "#{n}_confirmation" }
     432        attr_accessor(*(attr_names.map { |n| "#{n}_confirmation" })
    433433 
    434434        validates_each(attr_names, configuration) do |record, attr_name, value| 
     
    463463        configuration.update(attr_names.extract_options!) 
    464464 
    465         attr_accessor *attr_names.reject { |name| column_names.include? name.to_s } 
     465        db_cols = begin 
     466          column_names 
     467        rescue ActiveRecord::StatementInvalid 
     468          [] 
     469        end 
     470        names = attr_names.reject { |name| db_cols.include?(name.to_s) } 
     471        attr_accessor(*names) 
    466472 
    467473        validates_each(attr_names,configuration) do |record, attr_name, value| 
  • trunk/activerecord/test/validations_test.rb

    r8301 r8377  
    301301    assert_equal "Dan Brown", reply["author_name"] 
    302302  end 
     303 
     304  def test_validates_acceptance_of_with_non_existant_table  
     305    Object.const_set :IncorporealModel, Class.new(ActiveRecord::Base)  
     306  
     307    assert_nothing_raised ActiveRecord::StatementInvalid do  
     308      IncorporealModel.validates_acceptance_of(:incorporeal_column)  
     309    end  
     310  end  
    303311 
    304312  def test_validate_presences