diff options
author | Jon Leighton <j@jonathanleighton.com> | 2011-05-21 01:30:00 -0700 |
---|---|---|
committer | Jon Leighton <j@jonathanleighton.com> | 2011-05-21 01:30:00 -0700 |
commit | d62a39a22b7ad56efa79089177aa06fda0d41f86 (patch) | |
tree | 1323af2dd5870c4d17863974550b6f9efca887e7 /activerecord/lib | |
parent | 7288682be4f9384ad4083415342d8af876f77db8 (diff) | |
parent | e0e8918003eab33c5446f17227c9035a6df75e5f (diff) | |
download | rails-d62a39a22b7ad56efa79089177aa06fda0d41f86.tar.gz rails-d62a39a22b7ad56efa79089177aa06fda0d41f86.tar.bz2 rails-d62a39a22b7ad56efa79089177aa06fda0d41f86.zip |
Merge pull request #1162 from guilleiguaran/singularize_individual_table_name
Singularize individual table name
Diffstat (limited to 'activerecord/lib')
-rw-r--r-- | activerecord/lib/active_record/associations/alias_tracker.rb | 4 | ||||
-rw-r--r-- | activerecord/lib/active_record/associations/join_helper.rb | 2 | ||||
-rw-r--r-- | activerecord/lib/active_record/base.rb | 4 |
3 files changed, 5 insertions, 5 deletions
diff --git a/activerecord/lib/active_record/associations/alias_tracker.rb b/activerecord/lib/active_record/associations/alias_tracker.rb index 44e2ee141e..bd98cf2f46 100644 --- a/activerecord/lib/active_record/associations/alias_tracker.rb +++ b/activerecord/lib/active_record/associations/alias_tracker.rb @@ -49,8 +49,8 @@ module ActiveRecord end end - def pluralize(table_name) - ActiveRecord::Base.pluralize_table_names ? table_name.to_s.pluralize : table_name.to_s + def pluralize(table_name, base) + base.pluralize_table_names ? table_name.to_s.pluralize : table_name.to_s end private diff --git a/activerecord/lib/active_record/associations/join_helper.rb b/activerecord/lib/active_record/associations/join_helper.rb index eae546e76e..87e33891a5 100644 --- a/activerecord/lib/active_record/associations/join_helper.rb +++ b/activerecord/lib/active_record/associations/join_helper.rb @@ -32,7 +32,7 @@ module ActiveRecord end def table_alias_for(reflection, join = false) - name = alias_tracker.pluralize(reflection.name) + name = alias_tracker.pluralize(reflection.name, reflection.active_record) name << "_#{alias_suffix}" name << "_join" if join name diff --git a/activerecord/lib/active_record/base.rb b/activerecord/lib/active_record/base.rb index 30e2d1a82c..92e525a361 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: |