diff options
author | David Heinemeier Hansson <david@loudthinking.com> | 2004-12-22 13:00:15 +0000 |
---|---|---|
committer | David Heinemeier Hansson <david@loudthinking.com> | 2004-12-22 13:00:15 +0000 |
commit | dcc486805e5d79bd10fd5dfe302302522d250e86 (patch) | |
tree | 8124ceffb3920233f662733c6d9496d880579427 /activerecord/lib | |
parent | 3f3cbb51dc20ecf7bbfa8e4fc6eb205ebe4e4c5c (diff) | |
download | rails-dcc486805e5d79bd10fd5dfe302302522d250e86.tar.gz rails-dcc486805e5d79bd10fd5dfe302302522d250e86.tar.bz2 rails-dcc486805e5d79bd10fd5dfe302302522d250e86.zip |
Fixed that Base.table_name would expect a parameter when used in has_and_belongs_to_many joins [Anna Lissa Cruz]
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@244 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'activerecord/lib')
-rw-r--r-- | activerecord/lib/active_record/associations/has_and_belongs_to_many_association.rb | 2 | ||||
-rwxr-xr-x | activerecord/lib/active_record/base.rb | 9 |
2 files changed, 3 insertions, 8 deletions
diff --git a/activerecord/lib/active_record/associations/has_and_belongs_to_many_association.rb b/activerecord/lib/active_record/associations/has_and_belongs_to_many_association.rb index 0da243786e..3f90d61e2d 100644 --- a/activerecord/lib/active_record/associations/has_and_belongs_to_many_association.rb +++ b/activerecord/lib/active_record/associations/has_and_belongs_to_many_association.rb @@ -5,7 +5,7 @@ module ActiveRecord super(owner, association_name, association_class_name, association_class_primary_key_name, options) @association_foreign_key = options[:association_foreign_key] || Inflector.underscore(Inflector.demodulize(association_class_name)) + "_id" - association_table_name = options[:table_name] || @association_class.table_name(association_class_name) + association_table_name = options[:table_name] || @association_class.table_name @join_table = join_table @order = options[:order] || "t.#{@association_class.primary_key}" diff --git a/activerecord/lib/active_record/base.rb b/activerecord/lib/active_record/base.rb index a7347c4af5..8a0fab2252 100755 --- a/activerecord/lib/active_record/base.rb +++ b/activerecord/lib/active_record/base.rb @@ -473,13 +473,8 @@ module ActiveRecord #:nodoc: # class Mouse < ActiveRecord::Base # def self.table_name() "mice" end # end - def table_name(class_name = nil) - if class_name.nil? - class_name = class_name_of_active_record_descendant(self) - table_name_prefix + undecorated_table_name(class_name) + table_name_suffix - else - table_name_prefix + undecorated_table_name(class_name) + table_name_suffix - end + def table_name + table_name_prefix + undecorated_table_name(class_name_of_active_record_descendant(self)) + table_name_suffix end # Defines the primary key field -- can be overridden in subclasses. Overwritting will negate any effect of the |