0
0
Ruby on Railsframework~20 mins

Heroku deployment in Ruby on Rails - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Heroku Deployment Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
component_behavior
intermediate
2:00remaining
What happens when you run heroku run rails db:migrate?

After deploying a Rails app to Heroku, you run heroku run rails db:migrate. What does this command do?

AIt runs the database migrations on the Heroku production database.
BIt runs migrations locally on your computer's database.
CIt restarts the Heroku app without running migrations.
DIt deletes the Heroku database and creates a new one.
Attempts:
2 left
💡 Hint

Think about where the app is running and where the database lives on Heroku.

📝 Syntax
intermediate
2:00remaining
Which Procfile entry correctly starts a Rails web server on Heroku?

You want to tell Heroku how to start your Rails app web server. Which Procfile line is correct?

Aweb: rails server -p 3000
Bweb: bundle exec rails server -p $PORT
Cweb: rails start
Dweb: bundle exec puma
Attempts:
2 left
💡 Hint

Heroku assigns a port dynamically. The command must use that port.

🔧 Debug
advanced
2:00remaining
Why does this Heroku deployment fail with a PG::ConnectionBad error?

You deployed your Rails app to Heroku but get this error in logs: PG::ConnectionBad: could not connect to server. What is the most likely cause?

AThe <code>DATABASE_URL</code> environment variable is missing or incorrect.
BThe Rails app is missing the <code>sqlite3</code> gem in production.
CThe <code>Procfile</code> is missing the web server command.
DThe <code>Gemfile.lock</code> is not committed to git.
Attempts:
2 left
💡 Hint

Heroku uses DATABASE_URL to connect to the database.

state_output
advanced
2:00remaining
What is the effect of running heroku config:set RAILS_ENV=production?

You run heroku config:set RAILS_ENV=production on your app. What does this change do?

AIt restarts the app without changing any environment variables.
BIt disables asset precompilation during deployment.
CIt sets the environment variable only for your local machine.
DIt sets the Rails environment to production on Heroku, affecting config and logging.
Attempts:
2 left
💡 Hint

Environment variables on Heroku control app behavior in the cloud.

🧠 Conceptual
expert
3:00remaining
Why must you precompile assets before deploying a Rails app to Heroku?

Rails uses asset precompilation before deployment. Why is this step necessary on Heroku?

ATo create database indexes for faster queries on Heroku Postgres.
BTo convert Ruby code into JavaScript for Heroku's server environment.
CTo generate optimized CSS and JavaScript files so the app loads faster in browsers.
DTo install all gems needed by the app before deployment.
Attempts:
2 left
💡 Hint

Think about what assets are and how browsers use them.