13 lines
No EOL
389 B
Ruby
13 lines
No EOL
389 B
Ruby
module Ext
|
|
module GroupFor
|
|
def self.extended(base)
|
|
if (ActiveRecord::Base.connection.adapter_name == 'PostgreSQL')
|
|
if base.table_exists?
|
|
base.scope :group_for, {:group => base.column_names.map { |col_name| "#{base.table_name}.#{col_name}" }}
|
|
end
|
|
else
|
|
base.scope :group_for, {:group => "#{base.quoted_table_name}.id"}
|
|
end
|
|
end
|
|
end
|
|
end |