diff options
author | Rafael Mendonça França <rafaelmfranca@gmail.com> | 2019-01-14 22:14:53 -0500 |
---|---|---|
committer | Rafael Mendonça França <rafaelmfranca@gmail.com> | 2019-01-17 16:08:33 -0500 |
commit | 67356f2034ab41305af7218f7c8b2fee2d614129 (patch) | |
tree | c3958ac31991a62092a39c94441847d9161eb628 /activerecord/lib/active_record | |
parent | d97980a16d76ad190042b4d8578109714e9c53d0 (diff) | |
download | rails-67356f2034ab41305af7218f7c8b2fee2d614129.tar.gz rails-67356f2034ab41305af7218f7c8b2fee2d614129.tar.bz2 rails-67356f2034ab41305af7218f7c8b2fee2d614129.zip |
Do not allow passing the column name to `count` when a block is passed
Diffstat (limited to 'activerecord/lib/active_record')
-rw-r--r-- | activerecord/lib/active_record/relation/calculations.rb | 10 |
1 files changed, 4 insertions, 6 deletions
diff --git a/activerecord/lib/active_record/relation/calculations.rb b/activerecord/lib/active_record/relation/calculations.rb index c2c4a5a882..40bae89170 100644 --- a/activerecord/lib/active_record/relation/calculations.rb +++ b/activerecord/lib/active_record/relation/calculations.rb @@ -41,15 +41,13 @@ module ActiveRecord def count(column_name = nil) if block_given? unless column_name.nil? - ActiveSupport::Deprecation.warn \ - "When `count' is called with a block, it ignores other arguments. " \ - "This behavior is now deprecated and will result in an ArgumentError in Rails 6.0." + raise ArgumentError, "Column name argument is not supported when a block is passed." end - return super() + super() + else + calculate(:count, column_name) end - - calculate(:count, column_name) end # Calculates the average value on a given column. Returns +nil+ if there's |