Ruby on rails 在Heroku上部署时出现ActionView错误(SQL/postgresql)
我将在Heroku中部署我的Ruby应用程序,我将我的Gemfile更改为在开发中使用sqlite,在生产中使用PG GemfileRuby on rails 在Heroku上部署时出现ActionView错误(SQL/postgresql),ruby-on-rails,ruby,postgresql,sqlite,heroku,Ruby On Rails,Ruby,Postgresql,Sqlite,Heroku,我将在Heroku中部署我的Ruby应用程序,我将我的Gemfile更改为在开发中使用sqlite,在生产中使用PG 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 'sqlit
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
我不知道如何修改我的查询和代码,使其与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 %>
réponses
谢谢你的帮助 如果您在开发中使用与在生产中使用相同的数据库,那么您将避免将来的许多痛苦和头痛。如果您坚持在dev中使用Sqlite,在生产中使用Postgres,那么将来也会遇到类似的问题。在开发机器上安装Postgres通常非常容易。你试过了吗?可能是重复的
<%= @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 %>