Flowdock
method

custom_counter_sql

Importance_0
v3.1.0 - Show latest stable - 0 notes - Class: CollectionAssociation
custom_counter_sql() private

No documentation

This method has no description. You can help the Ruby on Rails community by adding new notes.

Hide source
# File activerecord/lib/active_record/associations/collection_association.rb, line 349
        def custom_counter_sql
          if options[:counter_sql]
            interpolate(options[:counter_sql])
          else
            # replace the SELECT clause with COUNT(*), preserving any hints within /* ... */
            interpolate(options[:finder_sql]).sub(/SELECT\b(\/\*.*?\*\/ )?(.*)\bFROM\b/m) { "SELECT #{$1}COUNT(*) FROM" }
          end
        end
Register or log in to add new notes.