服务器上的混合轨道环境



出于某种原因,我使用的Rails应用程序有一个混合环境。例如,应用程序使用 config/environment/production.rb 并记录到 log/production.rb,但使用 config/database.yml 中的开发设置,"rake about"显示开发模式:

About your application's environment
Rails version             4.2.7.1
Ruby version              2.1.9-p495 (x86_64-linux-gnu)
RubyGems version          2.4.5.4
Rack version              1.6.5
JavaScript Runtime        Node.js (V8)
Middleware                Rack::Sendfile, ActionDispatch::Static, Rack::Lock, #<ActiveSupport::Cache::Strategy::LocalCache::Middleware:0x0000000633e5b8>, Rack::Runtime, Rack::MethodOverride, ActionDispatch::RequestId, Rails::Rack::Logger, ActionDispatch::ShowExceptions, ActionDispatch::DebugExceptions, ActionDispatch::RemoteIp, ActionDispatch::Reloader, ActionDispatch::Callbacks, ActiveRecord::Migration::CheckPending, ActiveRecord::ConnectionAdapters::ConnectionManagement, ActiveRecord::QueryCache, ActionDispatch::Cookies, ActionDispatch::Session::CookieStore, ActionDispatch::Flash, ActionDispatch::ParamsParser, Rack::Head, Rack::ConditionalGet, Rack::ETag, Warden::Manager, HttpAcceptLanguage::Middleware, OmniAuth::Strategies::GoogleOauth2
Application root          /var/www/[#########]
Environment               development
Database adapter          mysql2
Database schema version   20191114203932

服务器运行Apache和Passenger。

如何为 Rails 应用程序的所有部分打开生产模式?

您的 Apache/乘客设置很可能正在将环境设置为生产环境。这仅适用于通过 Apache 发送的 Web (HTTP( 请求。

作为默认的 rake/rails 在开发模式下运行,除非另有说明。您可以通过设置常量RAILS_ENV来执行此操作。这可以通过设置 bash 脚本或在运行命令时进行,例如:

RAILS_ENV=production rake about

最新更新