0
0
Ruby on Railsframework~10 mins

Why deployment preparation matters in Ruby on Rails - Test Your Understanding

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to set the Rails environment to production before deployment.

Ruby on Rails
Rails.env = '[1]'
Drag options to blanks, or click blank then click option'
Aproduction
Bdevelopment
Ctest
Dstaging
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'development' instead of 'production' causes the app to run with debug settings.
Forgetting to set the environment can lead to unexpected behavior.
2fill in blank
medium

Complete the code to precompile assets before deployment.

Ruby on Rails
rails assets:[1]
Drag options to blanks, or click blank then click option'
Abuild
Bclean
Ccompile
Dprecompile
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'compile' instead of 'precompile' will cause errors.
Skipping asset precompilation can slow down the app.
3fill in blank
hard

Fix the error in the database configuration for production.

Ruby on Rails
production:
  adapter: postgresql
  encoding: unicode
  database: myapp_[1]
  pool: 5
  username: myapp
  password: <%= ENV['MYAPP_DATABASE_PASSWORD'] %>
Drag options to blanks, or click blank then click option'
Aproduction
Btest
Cdevelopment
Dstaging
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'development' or 'test' database names in production causes connection errors.
Not matching the environment name leads to wrong database usage.
4fill in blank
hard

Fill both blanks to configure the secret key base for production.

Ruby on Rails
production:
  secret_key_base: <%= ENV['[1]'] %>
  host: '[2]'
Drag options to blanks, or click blank then click option'
ASECRET_KEY_BASE
BDATABASE_URL
Cexample.com
Dlocalhost
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'DATABASE_URL' instead of 'SECRET_KEY_BASE' for the secret key.
Setting host to 'localhost' instead of the real domain.
5fill in blank
hard

Fill all three blanks to create a safe deployment script snippet.

Ruby on Rails
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
end
Drag options to blanks, or click blank then click option'
Acurrent
Btxt
C/var/www/myapp
Dlog
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'log' instead of 'current' for the restart path.
Using 'txt' incorrectly or missing the file extension.
Setting the path to 'log' instead of the app folder.