wag*_*325 4 postgresql ruby-on-rails heroku
我在使用SQLite3将现有应用程序更改为postgreSQL时遇到问题.我正在按照本教程将SQLite3转换为postgreSQL并将其部署到heroku:https://devcenter.heroku.com/articles/sqlite3#running-rails-on-postgres .
我删除了gem'sqlite3'并替换为gem'pg'.修改config/database.yml后,我运行了迁移.
$rake db:create并$rake db:migrate导致此错误:
could not connect to server: No such file or directory
Is the server running locally and accepting
connections on Unix domain socket "/var/pgsql_socket/.s.PGSQL.5432"?
Run Code Online (Sandbox Code Playgroud)
生产中使用的Gemfile:
gem 'rails_12factor'
gem 'thin'
gem 'pg'
Run Code Online (Sandbox Code Playgroud)
以下是我使用本地服务器运行时出现的错误:
/usr/local/rvm/gems/ruby-2.0.0-p353/gems/activerecord-4.0.0/lib/active_record/connection_adapters/postgresql_adapter.rb:825:in `initialize': could not connect to server: No such file or directory (PG::ConnectionBad)
Is the server running locally and accepting
connections on Unix domain socket "/var/pgsql_socket/.s.PGSQL.5432"?
Run Code Online (Sandbox Code Playgroud)
您好像没有在Heroku帐户中添加Heroku Postgres数据库.配置数据库后,您的应用程序将连接到该数据库.如果没有配置数据库,它将回退到本地查找数据库.
如果您确实配置了数据库,则Heroku环境会出现问题,导致无法找到数据库连接设置.