Changeset 4992
- Timestamp:
- 09/04/06 18:55:30 (2 years ago)
- Files:
-
- trunk/activerecord/CHANGELOG (modified) (1 diff)
- trunk/activerecord/lib/active_record/associations.rb (modified) (1 diff)
- trunk/activerecord/test/associations_test.rb (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/activerecord/CHANGELOG
r4990 r4992 1 1 *SVN* 2 3 * Add deprecation warning for inferred foreign key. #6029 [Josh Susser] 2 4 3 5 * Fixed the Ruby/MySQL adapter we ship with Active Record to work with the new authentication handshake that was introduced in MySQL 4.1, along with the other protocol changes made at that time #5723 [jimw@mysql.com] trunk/activerecord/lib/active_record/associations.rb
r4981 r4992 656 656 # belongs_to :attachable, :polymorphic => true 657 657 def belongs_to(association_id, options = {}) 658 if options.include?(:class_name) && !options.include?(:foreign_key) 659 ::ActiveSupport::Deprecation.warn( 660 "The inferred foreign_key name will change in Rails 2.0 to use the association name instead of its class name when they differ. When using :class_name in belongs_to, use the :foreign_key option to explicitly set the key name to avoid problems in the transition.", 661 caller) 662 end 663 658 664 reflection = create_belongs_to_reflection(association_id, options) 659 665 trunk/activerecord/test/associations_test.rb
r4981 r4992 351 351 end 352 352 353 def test_deprecated_inferred_foreign_key 354 assert_not_deprecated { Company.belongs_to :firm } 355 assert_not_deprecated { Company.belongs_to :client, :foreign_key => "firm_id" } 356 assert_not_deprecated { Company.belongs_to :firm, :class_name => "Firm", :foreign_key => "client_of" } 357 assert_deprecated("inferred foreign_key name") { Company.belongs_to :client, :class_name => "Firm" } 358 end 359 353 360 end 354 361