Skip to content

Instantly share code, notes, and snippets.

@balexand
Created July 14, 2011 20:27
Show Gist options
  • Save balexand/1083358 to your computer and use it in GitHub Desktop.
Save balexand/1083358 to your computer and use it in GitHub Desktop.
# when I call Thing.count, it works and DISTINCT records are selected
# when I call Thing.scoped.count (or any other query), it doesn't work
class Thing < ActiveRecord::Base
class << self
def count_with_distinct
count_without_distinct(:distinct => true)
end
alias_method_chain :count, :distinct
end
...
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment