0
votes

For some reason the Rails application I work with has a mixed environment. For example the application uses config/environments/production.rb and is logging to log/production.rb, but uses development settings from config/database.yml and "rake about" shows development mode:

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

Server runs Apache and Passenger.

How can I turn on production mode for all parts of Rails application?

1
How are you specifying the rails env in prod ? - Vatsal Jain

1 Answers

0
votes

It's likely that your Apache/Passenger setup is setting the environment to production. This is only for web (HTTP) requests that come through Apache.

As a default rake/rails is run in development mode unless specified otherwise. You can do this by setting the constant RAILS_ENV. This can either by setting in a bash script or as your run the command, e.g.:

RAILS_ENV=production rake about