[Ruby] Settings that should be set when operating a production environment with Rails

less than 1 minute read

Make the error display on the browser the same in development and production environments

First, when ERROR occurs in the development environment, detailed information will be displayed in the browser. 8c1d32d1432226f625cab33c2ed1fcc7.png However, in the production environment, “We’re sorry, but something went wrong.” is displayed even if some kind of ERROR occurs. picture_pc_f8886f63bd354c264487153ad2c5c567.png So to display detailed information in the browser even in the production environment Set config.consider_all_requests_local = false to true.


config.consider_all_requests_local = true

Rails docs

Reset DB in production environment

In the production environment of Rails 5 or later, a function to prevent the execution of commands such as db:drop and db:reset that destroy the DB has been added. Therefore, an error will occur even if you execute bundle exec rake db:migrate:reset RAILS_ENV=production in a production environment.


Specify DISABLE_DATABASE_ENVIRONMENT_CHECK=1 in the environment variable.

$ bundle exec rake db:migrate:reset RAILS_ENV=production DISABLE_DATABASE_ENVIRONMENT_CHECK=1

Rake db:drop is not possible in Rails 5 production, normally

Settings under Rails config/enviroments that you should know

You may find the clue of the solution when you get stuck in the production environment by going through the following sites. Read under Rails config/enviroments

Tags: ,