[英]rails - how to run in production mode against the development database?
I'm in the process of updating an app to use asset compilation.我正在更新应用程序以使用资产编译。
I want to try running the server locally in production mode so I do我想尝试在生产模式下在本地运行服务器,所以我这样做
RAILS_ENV=production rails server
and it tries to start up in production mode:并尝试以生产模式启动:
=> Rails 3.1.8 application starting in production on http://0.0.0.0:3000
but aborts with但中止
=> Ctrl-C to shutdown server
Exiting
/home/durrantm/.rvm/gems/ruby-1.9.3-p194@linker/gems/activerecord-3.1.8/lib/active_record/connection_adapters/abstract/connection_specification.rb:71:in `rescue in establish_connection':
Please install the pg adapter: `gem install activerecord-pg-adapter` (cannot load such file -- active_record/connection_adapters/pg_adapter) (RuntimeError)
as I have to use postgres in production for a Heroku deploy.因为我必须在生产环境中使用 postgres 进行 Heroku 部署。
Locally I use mysql2 and I need to use the data there when running locally.在本地我使用 mysql2 并且在本地运行时我需要使用那里的数据。
I thought I could just temporarily remove the pg
reference in the Gemfile
production group and use mysql
instead, ie我想我可以暂时删除
Gemfile
生产组中的pg
引用并使用mysql
代替,即
group :production
# gem "pg" # Used for Production for heroku.
gem 'mysql2'
end
and I did a bundle install but I still get the pg adapter error - even though I don't have it in my Gemfile and I've bundled.并且我进行了捆绑安装,但我仍然收到 pg 适配器错误 - 即使我的 Gemfile 中没有它并且我已经捆绑了。 There's only 1 Gemfile.lock so I assume I don't need to do
RAILS_ENV=production bundle
, though of course I tried it - it didn't help.只有 1 个 Gemfile.lock 所以我假设我不需要做
RAILS_ENV=production bundle
,当然我试过了 - 它没有帮助。
My Gemfile lists mysql2 as a dependency and not pg我的 Gemfile 将 mysql2 列为依赖项而不是 pg
How can I get the server running locally in production mode against my mysql database?如何让服务器在生产模式下针对我的 mysql 数据库在本地运行?
Have you changed the production node in your database.yml
to use mysql2 adapter? 您是否已将
database.yml
的生产节点更改为使用mysql2适配器?
production:
adapter: mysql2
database: your_database
host: 127.0.0.1
username:
password:
in Gemfile在 Gemfile 中
group :production, :staging do
gem 'mysql2'
end
In config/database.yml在配置/数据库.yml
production:
adapter: mysql2
database: your_database
host: 127.0.0.1
username: your_username
password: your_password
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.