2

I'm deploying my Ruby app in Heroku, I've changed my Gemfile to use sqlite in development and PG in production

Gemfile

group :development, :test do
# Call 'byebug' anywhere in the code to stop execution and get a debugger 
console
gem 'byebug'
# Use sqlite3 as the database for Active Record
gem 'sqlite3'
end

group :development do
# Access an IRB console on exception pages or by using <%= console %> in views
gem 'web-console', '~> 2.0'

# Spring speeds up development by keeping your application running in the background. Read more: https://github.com/rails/spring
gem 'spring'

end

group :production do
gem 'pg', '~> 0.11'
gem 'rails_12factor'
end

I have a problem in my heroku logs :

 **ActionView::Template::Error (PG::GroupingError: ERROR:  column "polls.id" must appear in the GROUP BY clause or be used in an aggregate function**

I don't know how to modify my query and my code to make it works with PG.

My view index.html.erb

                    <%= @polls.where(question_id: Question.where(formulaire_id: @formulaire)[i]).length  %> réponses


                    <% @polls.select(:created_at).where(question_id: Question.where(formulaire_id: @formulaire.id)[i]).as_json(only: [:created_at]).uniq{|x| x.to_s} %> 

                    <% @NbRepondant = @polls.select(:created_at).where(question_id: Question.where(formulaire_id: @formulaire.id)[i]).as_json(only: [:created_at]).uniq{|x| x.to_s}.length %>

Thank you for your help !

Sox -
  • 592
  • 1
  • 9
  • 28
  • 3
    You will save yourself a lot of future pain and headache if you use the same database in development as you are using in production. If you insist on using Sqlite in dev and Postgres in production, you are going to have similar problems in the future. It's generally pretty easy to install Postgres on a development machine. Have you tried? – moveson Mar 19 '18 at 21:25
  • 1
    Possible duplicate of [GroupingError: ERROR: column must appear in the GROUP BY clause or be used in an aggregate function](https://stackoverflow.com/questions/20942477/groupingerror-error-column-must-appear-in-the-group-by-clause-or-be-used-in-an) – Alexander Presber Mar 20 '18 at 05:44

0 Answers0