Chapter 20. Pushing Further into Rails

If an expert says it can’t be done, get another expert.

David Ben-Gurion

At this point, Rails should seem much less mysterious. You should understand how to build fairly sophisticated Rails applications, and the magic of assembling applications by naming convention. As much as you’ve learned, though, you could go much further.

Changing to Production Mode

So far, you’ve likely been running all of your code in development or testing mode. Shifting to production mode is kind of like graduating. Running your application in production mode means that it runs all of its queries against your production database, and that it loads the Rails configuration from config/environments/production.rb. You also should precompile your assets with bundle exec rails assets:precompile, as the production environment won’t do that automatically. (You can set Rails up to do that, but it will likely create efficiency problems.)

Because of the way Rails is set up by default, the shift in environments to production mode results in changes to the following configuration settings:

config.cache_classes = true

Rails doesn’t check to see if any code has changed every request, so everything runs a lot faster in production mode.

config.action_controller.perform_caching = true

Caching is enabled, letting Rails optimize its performance by minimizing redundant processing.

config.action_controller.consider_all_requests_local = false

Verbose error reporting ...

Get Learning Rails 5 now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.