2011-03-25 64 views
6

我试图将我的Rails 3应用程序上传到真实的生产环境。 (该应用程序在我的本地机器上完美运行)。如何在部署时告诉Rails使用生产数据库(而不是开发数据库)?

当我运行轨Ç我得到了以下错误:

/home/misha_moroshko/.gems/gems/activerecord-3.0.1/lib/active_record/connection_adapters/abstract/connection_specification.rb:62:in `establish_connection': development database is not configured (ActiveRecord::AdapterNotSpecified) 
     from /home/misha_moroshko/.gems/gems/activerecord-3.0.1/lib/active_record/connection_adapters/abstract/connection_specification.rb:55:in `establish_connection' 
     from /home/misha_moroshko/.gems/gems/activerecord-3.0.1/lib/active_record/railtie.rb:59 
     from /home/misha_moroshko/.gems/gems/activesupport-3.0.1/lib/active_support/lazy_load_hooks.rb:36:in `instance_eval' 

我该如何告诉它应该与生产数据库而不是开发一个Rails的工作?

回答

21

将RAILS_ENV环境变量第一,或者将它传递给钢轨C命令:

RAILS_ENV=production rails c 

rails c production 
1

这很大程度上取决于您要部署到的“环境”。对于Apache和乘客,可以设置:

# conf/passenger.conf 
RailsEnv production 
RackEnv production 
4

什么在你的database.yml中?它应该有一个生产环境,你需要告诉轨要在生产环境中运行它:

rails c production 
相关问题