diff --git a/activerecord/CHANGELOG b/activerecord/CHANGELOG index 8f3846a4823e632e53fdbb1f1b50fcea8a00df2e..74780f52dd99af30133ad22c95e5a5bc0841c6f9 100644 --- a/activerecord/CHANGELOG +++ b/activerecord/CHANGELOG @@ -1,5 +1,7 @@ *SVN* +* Fixed that :counter_cache option would look for a line_items_count column for a LineItem object instead of lineitems_count + * Fixed that AR exists?() would explode on postgresql if the passed id did not match the PK type #900 [Scott Barron] * Fixed the MS SQL adapter to work with the new limit/offset approach and with binary data (still suffering from 7KB limit, though) #901 [delynnb] diff --git a/activerecord/lib/active_record/associations.rb b/activerecord/lib/active_record/associations.rb index 229cfb5cfa53ddde4ef47d9f53060a974b469ce7..f9f5ec98a6acf328267aa7845e48616a43026e4e 100755 --- a/activerecord/lib/active_record/associations.rb +++ b/activerecord/lib/active_record/associations.rb @@ -376,12 +376,12 @@ def belongs_to(association_id, options = {}) if options[:counter_cache] module_eval( - "after_create '#{association_class_name}.increment_counter(\"#{Inflector.pluralize(self.to_s.downcase). + "_count"}\", #{association_class_primary_key_name})" + + "after_create '#{association_class_name}.increment_counter(\"#{self.to_s.underscore.pluralize + "_count"}\", #{association_class_primary_key_name})" + " unless #{association_name}.nil?'" ) module_eval( - "before_destroy '#{association_class_name}.decrement_counter(\"#{Inflector.pluralize(self.to_s.downcase) + "_count"}\", #{association_class_primary_key_name})" + + "before_destroy '#{association_class_name}.decrement_counter(\"#{self.to_s.underscore.pluralize + "_count"}\", #{association_class_primary_key_name})" + " unless #{association_name}.nil?'" ) end