Skip to content

Instantly share code, notes, and snippets.

@beef
Created June 23, 2009 12:33
Show Gist options
  • Save beef/134510 to your computer and use it in GitHub Desktop.
Save beef/134510 to your computer and use it in GitHub Desktop.
class ActiveRecord::Base
protected
def self.construct_count_options_from_args(*args)
name_and_options = super
if name_and_options[0].is_a?(String)
if name_and_options[0].include?(',')
name_and_options[0] = "DISTINCT #{quoted_table_name}.#{primary_key}"
elsif name_and_options[0] =~ /\.\*$/
name_and_options[0] = '*'
end
end
name_and_options
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment