In Rails, what is the main reason to precompile assets before deployment?
Think about how browsers load styles and scripts efficiently.
Precompiling assets combines and compresses CSS and JavaScript files. This reduces the number of requests and file sizes, making pages load faster for users.
Consider a Rails app deployment where database migrations are not run. What is the likely outcome when the app starts?
Think about how Rails uses migrations to keep the database structure in sync with the code.
Skipping migrations means the database schema may not match the app's expectations. This causes errors when the app tries to access missing tables or columns.
During deployment, the Rails app logs show: ActionController::RoutingError (No route matches [GET] "/assets/application.js"). What is the most likely cause?
Focus on the missing asset file in the error message.
The error shows the app can't find the JavaScript asset. This usually happens if assets were not precompiled, so the files don't exist in the public folder.
If a migration fails halfway during deployment, what is the likely state of the database and app?
Consider what happens if a migration script stops in the middle.
Failed migrations can leave the database in a half-changed state, which can cause errors or unexpected behavior until fixed.
In config/environments/production.rb, which line correctly configures Rails to log to standard output for deployment environments like Heroku?
Look for the correct class used by Rails for logging.
Rails uses ActiveSupport::Logger to handle logging. Setting config.logger = ActiveSupport::Logger.new(STDOUT) sends logs to standard output.