I\'ve got a rails app that works fine in development (SQLite) but is throwing lots of errors when I\'ve deployed it via Heroku, which uses PostgreSQL I gather.
the e
You need to group by all the columns in the select list, so
.group("practices.id, practices.foo, practices.bar, ..., DATE(created_at)")
Your idea to group only by id
is sound (assuming id
is the primary key), but PostgreSQL will only support that in version 9.1.
Practice.joins(:foobar).group_all
def self.group_all
group(group_all_columns)
end
def self.group_all_columns
@group_all_columns ||= column_names.collect {|c| "#{table_name}.#{c}"}.join(",")
end
Practice.group(Practice.col_list)
def self.col_list
Practice.column_names.collect {|c| "practices.#{c}"}.join(",")
end