我正在使用 mysql 开发我的应用程序,但我使用 Heroku 来部署它并被迫使用 PG。
我对以下语句有疑问:
<% current_user_savings = Saving.where{user_id == my{current_user}} %>
<% @latest_savings = Saving.where{product_id.not_in(current_user_savings.select{product_id})}.group{product_id} %>
所以它可以在我的电脑上运行,但是在部署到 heroku 时,我遇到了以下问题:
ActionView::Template::Error (PGError: ERROR: column "savings.id" must appear in the GROUP BY clause or be used in an aggregate function
LINE 1: SELECT "savings".* FROM "savings" WHERE "savings"."product_...
SELECT "savings".* FROM "savings" WHERE "savings"."product_id" NOT IN (SELECT "savings"."product_id" FROM "savings" WHERE "savings"."user_id" = 1) GROUP BY "savings"."product_id"):
我真的不知道如何解决这个问题并让它在heroku上工作。
请求的 Gemfile:来源 'https://rubygems.org'
ruby '1.9.3'
gem 'rails', '3.2.7'
gem 'compass_twitter_bootstrap', '2.0.3'
gem 'bcrypt-ruby', '3.0.1'
gem 'faker', '1.0.1'
gem 'will_paginate', '3.0.3'
gem 'bootstrap-will_paginate', '0.0.6'
gem 'omniauth-facebook', '1.4.0'
gem 'railroady'
gem 'devise', '2.1.2'
gem 'devise_invitable'
gem 'simple_form'
gem "mongoid", "~> 3.0.0"
gem 'thin'
gem 'best_in_place'
gem "jquery-fileupload-rails"
gem 'paperclip'
gem "squeel"
gem 'client_side_validations'
gem 'wicked'
gem 'koala'
gem 'aws-sdk'
gem 'bson_ext'
group :development, :test do
gem 'sqlite3'
end
group :development, :test do
gem 'annotate', '2.5.0'
end
group :test, :development do
gem 'rspec-rails'
end
group :assets do
gem 'sass-rails', '~> 3.2.3'
gem 'compass-rails', '1.0.3'
gem 'coffee-rails', '~> 3.2.1'
gem 'uglifier', '>= 1.0.3'
end
gem 'jquery-rails'
gem 'jquery-ui-rails'
group :test do
gem 'capybara'
gem 'factory_girl_rails'
end
group :production do
gem 'pg', '0.12.2'
end