1

我正在更新应用程序以使用资产编译过程。rails - 如何在生产模式下针对开发数据库运行?

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

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/[email protected]/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适配器错误 - 尽管我没有在我的Gemfile中,我已经捆绑了。只有1 Gemfile.lock,所以我假设我不需要做RAILS_ENV=production bundle,虽然我尝试了它 - 它没有帮助。

我的Gemfile列出mysql2作为一个依赖,而不是皮克

我怎样才能获得本地生产模式对我的MySQL数据库运行的服务器?

回答

1

您是否更改过database.yml中的生产节点以使用mysql2适配器?

production: 
    adapter: mysql2 
    database: your_database 
    host: 127.0.0.1 
    username: 
    password: 
+0

我没有和改变它的帮助。不幸的是,我现在正在 - '... rescue in depend_on':没有这样的文件加载 - /home/durrantm/.../linker/app/assets/../config/environment(LoadError)'。任何想法,为什么? –

+0

比较你的文件config/environments/development.rb和..production.rb,看起来像缺少某些东西。 –

+0

顺便说一句,它看起来可能来自config.ru,它具有'require :: File.expand_path('../ config/environment',__FILE__) '。请注意 - 这是一个较旧的(最初是rails 2)应用程序。 –

相关问题