Complete the code to set the Rails environment to production before deployment.
Rails.env = '[1]'
Setting Rails.env to production ensures the app runs with production settings during deployment.
Complete the code to precompile assets before deployment.
rails assets:[1]Running rails assets:precompile prepares CSS and JavaScript files for production.
Fix the error in the database configuration for production.
production: adapter: postgresql encoding: unicode database: myapp_[1] pool: 5 username: myapp password: <%= ENV['MYAPP_DATABASE_PASSWORD'] %>
The production database name should include 'production' to match the environment.
Fill both blanks to configure the secret key base for production.
production: secret_key_base: <%= ENV['[1]'] %> host: '[2]'
The secret key base is stored in the environment variable SECRET_KEY_BASE. The host should be the live domain like example.com.
Fill all three blanks to create a safe deployment script snippet.
namespace :deploy do
task :restart do
on roles(:app) do
execute :touch, '[1]/tmp/restart.[2]'
end
end
after :publishing, :restart
after :restart, :clear_cache do
on roles(:web), in: :groups, limit: 3, wait: 10 do
within '[3]' do
execute :rake, 'cache:clear'
end
end
end
endThe touch command updates tmp/restart.txt inside the current folder to restart the app. The cache clear runs inside the app folder /var/www/myapp.