簡體   English   中英

如何在部署時告訴Rails使用生產數據庫(而不是開發數據庫)?

[英]How to tell Rails to work with the production database (rather than development one) when deploying?

我正在嘗試將我的Rails 3應用程序上傳到真實的生產環境。 (該應用程序在我的本地計算機上完美運行)。

當我運行rails c時出現以下錯誤:

/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它應該與生產數據庫而不是開發數據庫一起使用?

首先設置RAILS_ENV環境變量,或將其傳遞給rails c命令:

RAILS_ENV=production rails c

要么

rails c production

你的database.yml里有什么? 它應該有一個生產設置,你需要告訴rails你想在生產中運行它:

rails c production

這在很大程度上取決於您要部署的“環境”。 對於Apache和Passenger,可以設置:

# conf/passenger.conf
RailsEnv production
RackEnv production

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM