diff options
-rw-r--r-- | activerecord/lib/active_record/base.rb | 4 | ||||
-rw-r--r-- | activerecord/test/cases/base_test.rb | 9 |
2 files changed, 11 insertions, 2 deletions
diff --git a/activerecord/lib/active_record/base.rb b/activerecord/lib/active_record/base.rb index cd16b8d3ca..1ece79adc0 100644 --- a/activerecord/lib/active_record/base.rb +++ b/activerecord/lib/active_record/base.rb @@ -393,8 +393,8 @@ module ActiveRecord #:nodoc: # Indicates whether table names should be the pluralized versions of the corresponding class names. # If true, the default table name for a Product class will be +products+. If false, it would just be +product+. # See table_name for the full rules on table/class naming. This is true, by default. - cattr_accessor :pluralize_table_names, :instance_writer => false - @@pluralize_table_names = true + class_attribute :pluralize_table_names, :instance_writer => false + self.pluralize_table_names = true ## # :singleton-method: diff --git a/activerecord/test/cases/base_test.rb b/activerecord/test/cases/base_test.rb index bfb66f07da..87ce537e0e 100644 --- a/activerecord/test/cases/base_test.rb +++ b/activerecord/test/cases/base_test.rb @@ -367,6 +367,15 @@ class BasicsTest < ActiveRecord::TestCase GUESSED_CLASSES.each(&:reset_table_name) end + def test_singular_table_name_guesses_for_individual_table + CreditCard.pluralize_table_names = false + CreditCard.reset_table_name + assert_equal "credit_card", CreditCard.table_name + assert_equal "categories", Category.table_name + ensure + CreditCard.pluralize_table_names = true + CreditCard.reset_table_name + end if current_adapter?(:MysqlAdapter) or current_adapter?(:Mysql2Adapter) def test_update_all_with_order_and_limit |