diff options
author | Jamis Buck <jamis@37signals.com> | 2006-03-04 19:42:41 +0000 |
---|---|---|
committer | Jamis Buck <jamis@37signals.com> | 2006-03-04 19:42:41 +0000 |
commit | ff881c7f8b1ffd855c09cabcd2c9b06aea4e850d (patch) | |
tree | d8c5aeeda94ad90d5a8a9a1ea4950bc9a5d585ae /activerecord/lib/active_record/reflection.rb | |
parent | eb01d35109897162a48ff5219dcd97f35328168c (diff) | |
download | rails-ff881c7f8b1ffd855c09cabcd2c9b06aea4e850d.tar.gz rails-ff881c7f8b1ffd855c09cabcd2c9b06aea4e850d.tar.bz2 rails-ff881c7f8b1ffd855c09cabcd2c9b06aea4e850d.zip |
Make counter cache work when replacing an association (closes #3245). Thanks for the patch!
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@3762 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'activerecord/lib/active_record/reflection.rb')
-rw-r--r-- | activerecord/lib/active_record/reflection.rb | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/activerecord/lib/active_record/reflection.rb b/activerecord/lib/active_record/reflection.rb index b9369feeb7..32e812a86a 100644 --- a/activerecord/lib/active_record/reflection.rb +++ b/activerecord/lib/active_record/reflection.rb @@ -131,6 +131,14 @@ module ActiveRecord @association_foreign_key ||= @options[:association_foreign_key] || class_name.foreign_key end + def counter_cache_column + if options[:counter_cache] == true + "#{active_record.name.underscore.pluralize}_count" + elsif options[:counter_cache] + options[:counter_cache] + end + end + private def name_to_class_name(name) if name =~ /::/ |