Forum: Ruby on Rails MySQL and Postgres

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
Fb15b4025c2802a463003269ca4ce869?d=identicon&s=25 Miguel A. (miguel_a85)
on 2012-05-29 14:48
Hello all,

I'm a RoR begginer and am developing my app using MySQL but Heroku uses
Postgres, so my arel isn't working quite properly.

I've searched about the outputted error but in my case, since I'm doing
a query between a HABTM table, things aren't going so well.

Basically, a Product has_and_belongs_to_many Categories. My relation is
all set and everything works locally, but on deploy a 500 error occurs.

So without further delay, the issue is:

(...previous queries that work good locally and on heroku...)
if params[:fc].present? (checks if checkboxes have been ticked)
          arel=arel.joins('INNER JOIN categories_products ON
products.id=categories_products.product_id')
          arel=arel.where('categories_products.category_id in
(:fc_list)', :fc_list => params[:fc]).uniq
          arel=arel.group('product_id').having('count(category_id) =
:size', :size => params[:fc].size)
 end

So the idea is to allow the user to check a checkbox list and then
display
all the products that are in the checked categories.

My heroku error is: "products.id" must appear in the GROUP BY clause or
be used in an aggregate function.

I know that there are already threads on this but none have fixed my
problem.

Thank you in advance.

Regards,
Miguel A.
This topic is locked and can not be replied to.