aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib
diff options
context:
space:
mode:
authorAndrew White <andyw@pixeltrix.co.uk>2013-03-15 03:31:30 -0700
committerAndrew White <andyw@pixeltrix.co.uk>2013-03-15 03:31:30 -0700
commitaa073188ae5d896542fb26a3211c6938c94c263c (patch)
treebe99d39ad7a99fd103f9625e2429111b1f8c2e1b /activerecord/lib
parentddb9040b433b00aa0206442aa718eee12bceb517 (diff)
parentb601399b72ab56cc01368f02615af99f45d14f02 (diff)
downloadrails-aa073188ae5d896542fb26a3211c6938c94c263c.tar.gz
rails-aa073188ae5d896542fb26a3211c6938c94c263c.tar.bz2
rails-aa073188ae5d896542fb26a3211c6938c94c263c.zip
Merge pull request #9731 from senny/9724_argument_error_on_reset_counters
`#reset_counters` verifies counter names.
Diffstat (limited to 'activerecord/lib')
-rw-r--r--activerecord/lib/active_record/counter_cache.rb3
1 files changed, 2 insertions, 1 deletions
diff --git a/activerecord/lib/active_record/counter_cache.rb b/activerecord/lib/active_record/counter_cache.rb
index 81f92db271..81cca37939 100644
--- a/activerecord/lib/active_record/counter_cache.rb
+++ b/activerecord/lib/active_record/counter_cache.rb
@@ -11,7 +11,7 @@ module ActiveRecord
# ==== Parameters
#
# * +id+ - The id of the object you wish to reset a counter on.
- # * +counters+ - One or more counter names to reset
+ # * +counters+ - One or more association counters to reset
#
# ==== Examples
#
@@ -21,6 +21,7 @@ module ActiveRecord
object = find(id)
counters.each do |association|
has_many_association = reflect_on_association(association.to_sym)
+ raise ArgumentError, "'#{self.name}' has no association called '#{association}'" unless has_many_association
if has_many_association.is_a? ActiveRecord::Reflection::ThroughReflection
has_many_association = has_many_association.through_reflection