Skip to content

Instantly share code, notes, and snippets.

@hosh
Created June 29, 2011 19:55
Show Gist options
  • Save hosh/1054766 to your computer and use it in GitHub Desktop.
Save hosh/1054766 to your computer and use it in GitHub Desktop.
Group By Helper
# Ugly hack until PostgreSQL 9.1 comes out.
module Models
module GroupByHelper
extend ActiveSupport::Concern
included do
scope :group_by_all, lambda { group(self.column_names.map { |c| "#{self.table_name}.#{c}" }.join(',')) }
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment