From d52cee3e3bb4c45bfd21d3f905e502fa00758def Mon Sep 17 00:00:00 2001 From: Rick Olson Date: Mon, 4 Sep 2006 18:55:30 +0000 Subject: Add deprecation warning for inferred foreign key. #6029 [Josh Susser] git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@4992 5ecf4fe2-1ee6-0310-87b1-e25e094e27de --- activerecord/lib/active_record/associations.rb | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'activerecord/lib/active_record/associations.rb') diff --git a/activerecord/lib/active_record/associations.rb b/activerecord/lib/active_record/associations.rb index 0771f26218..33fd8afee2 100755 --- a/activerecord/lib/active_record/associations.rb +++ b/activerecord/lib/active_record/associations.rb @@ -655,6 +655,12 @@ module ActiveRecord # :conditions => 'discounts > #{payments_count}' # belongs_to :attachable, :polymorphic => true def belongs_to(association_id, options = {}) + if options.include?(:class_name) && !options.include?(:foreign_key) + ::ActiveSupport::Deprecation.warn( + "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.", + caller) + end + reflection = create_belongs_to_reflection(association_id, options) if reflection.options[:polymorphic] -- cgit v1.2.3