Chapter 20. Pushing Further into Rails
At this point, Rails should seem much less mysterious. You should understand how to build fairly sophisticated Rails applications, the magic of assembling applications by naming convention. As much as you’ve learned, though, there’s much further that you could go.
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 Rails’ configuration
from config/environments/production.rb. You also should precompile your assets with bundle exec rake
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.)
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=trueRails 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=trueCaching is enabled, letting Rails optimize its performance by minimizing redundant processing.
config.action_controller.consider_all_requests_local=falseVerbose error reporting is disabled, so Rails won’t confess all to total strangers. Only users coming in from localhost (on the same ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access