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
=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 is disabled, so Rails won’t confess all to total strangers. Only users coming in from localhost (on the same ...
Get Learning Rails 3 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.