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

Changeset 8208

Show
Ignore:
Timestamp:
11/25/07 22:34:46 (2 years ago)
Author:
david
Message:

Allow validates_acceptance_of to use a real attribute instead of only virtual (so you can record that the acceptance occured) (closes #7457) [ambethia]

Files:

Legend:

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

    r8199 r8208  
    11*SVN* 
     2 
     3* Allow validates_acceptance_of to use a real attribute instead of only virtual (so you can record that the acceptance occured) #7457 [ambethia] 
    24 
    35* DateTimes use Ruby's default calendar reform setting. #10201 [Geoff Buesing] 
  • trunk/activerecord/lib/active_record/validations.rb

    r8172 r8208  
    415415      #   end 
    416416      # 
    417       # The terms_of_service attribute is entirely virtual. No database column is needed. This check is performed only if 
    418       # terms_of_service is not nil and by default on save. 
     417      # If the database column does not exist, the terms_of_service attribute is entirely virtual. This check is 
     418      # performed only if terms_of_service is not nil and by default on save. 
    419419      # 
    420420      # Configuration options: 
     
    434434        configuration.update(attr_names.extract_options!) 
    435435 
    436         attr_accessor *attr_names 
     436        attr_accessor *attr_names.reject { |name| column_names.include? name.to_s } 
    437437 
    438438        validates_each(attr_names,configuration) do |record, attr_name, value| 
  • trunk/activerecord/test/validations_test.rb

    r8172 r8208  
    2424class UniqueReply < Reply 
    2525  validates_uniqueness_of :content, :scope => 'parent_id' 
     26end 
     27 
     28class PlagiarizedReply < Reply 
     29  validates_acceptance_of :author_name 
    2630end 
    2731 
     
    291295    t.terms_of_service = "I agree." 
    292296    assert t.save 
     297  end 
     298 
     299  def test_validates_acceptance_of_as_database_column 
     300    reply = PlagiarizedReply.create("author_name" => "Dan Brown") 
     301    assert_equal "Dan Brown", reply["author_name"] 
    293302  end 
    294303