rails-如何针对开发数据库在生产模式下运行?

问题描述 投票:1回答:1

我正在更新应用程序以使用资产编译。

我想尝试以生产模式在本地运行服务器,所以我这样做

RAILS_ENV=production rails server

并尝试以生产模式启动:

=> Rails 3.1.8 application starting in production on http://0.0.0.0:3000

但是中止

=> 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)

因为我必须在生产中使用postgres进行Heroku部署。
我在本地使用mysql2,在本地运行时需要使用那里的数据。

我以为我可以暂时删除Gemfile生产组中的pg引用,并改用mysql ,即

group :production
#  gem "pg" # Used for Production for heroku.
  gem 'mysql2'
end

并且我做了一个捆绑安装,但是我仍然收到pg adapter错误-即使我的Gemfile中没有它,并且已经捆绑了。 只有1个Gemfile.lock,所以我认为我不需要做RAILS_ENV=production bundle ,尽管我当然尝试了-它没有帮助。

我的Gemfile将mysql2列为依赖项而不是pg

如何使服务器针对mysql数据库在生产模式下本地运行?

mysql ruby-on-rails development-environment production-environment pg
1个回答
1
投票

您是否已将database.yml的生产节点更改为使用mysql2适配器?

production:
    adapter: mysql2
    database: your_database
    host: 127.0.0.1
    username:
    password:
© www.soinside.com 2019 - 2024. All rights reserved.