aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib
diff options
context:
space:
mode:
authorRick Olson <technoweenie@gmail.com>2007-07-16 20:21:36 +0000
committerRick Olson <technoweenie@gmail.com>2007-07-16 20:21:36 +0000
commit4ef5af8d4ddad82295920cc7d83fba6cbb10ad71 (patch)
tree62a78541994ec67ea0065622ed05509e62538e68 /activerecord/lib
parentddb00f10781e808360a189b46a421f1d18a0360b (diff)
downloadrails-4ef5af8d4ddad82295920cc7d83fba6cbb10ad71.tar.gz
rails-4ef5af8d4ddad82295920cc7d83fba6cbb10ad71.tar.bz2
rails-4ef5af8d4ddad82295920cc7d83fba6cbb10ad71.zip
Change belongs_to so that the foreign_key assumption is taken from the association name, not the class name. Closes #8992 [hasmanyjosh]
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@7188 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'activerecord/lib')
-rwxr-xr-xactiverecord/lib/active_record/associations.rb6
-rw-r--r--activerecord/lib/active_record/reflection.rb2
2 files changed, 1 insertions, 7 deletions
diff --git a/activerecord/lib/active_record/associations.rb b/activerecord/lib/active_record/associations.rb
index ca739eb5dc..b9839a8500 100755
--- a/activerecord/lib/active_record/associations.rb
+++ b/activerecord/lib/active_record/associations.rb
@@ -799,12 +799,6 @@ 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]
diff --git a/activerecord/lib/active_record/reflection.rb b/activerecord/lib/active_record/reflection.rb
index 62184eeff2..3d76ffe776 100644
--- a/activerecord/lib/active_record/reflection.rb
+++ b/activerecord/lib/active_record/reflection.rb
@@ -207,7 +207,7 @@ module ActiveRecord
def derive_primary_key_name
if macro == :belongs_to
- class_name.foreign_key
+ "#{name}_id"
elsif options[:as]
"#{options[:as]}_id"
else