Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/ruby-on-rails/63.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/bash/17.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ruby on rails 在Heroku上部署时出现ActionView错误(SQL/postgresql)_Ruby On Rails_Ruby_Postgresql_Sqlite_Heroku - Fatal编程技术网

Ruby on rails 在Heroku上部署时出现ActionView错误(SQL/postgresql)

Ruby 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

我将在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 '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 %>