Recall & Review
beginner
What is the purpose of a Gemfile in a Rails project?
A Gemfile lists all the Ruby gems (libraries) your Rails app needs. It helps manage and install these dependencies easily.
Click to reveal answer
beginner
How do you specify a gem version in a Gemfile?
You add the gem name followed by a version requirement in quotes, like:
gem 'rails', '~> 7.0'. This tells Bundler which version to use.Click to reveal answer
beginner
What command installs the gems listed in the Gemfile?
Run
bundle install. It reads the Gemfile and installs all required gems and their dependencies.Click to reveal answer
intermediate
What is the role of the Gemfile.lock file?
Gemfile.lock records the exact gem versions installed. It ensures everyone working on the project uses the same gem versions for consistency.
Click to reveal answer
intermediate
How can you group gems for specific environments in a Gemfile?
Use groups like
group :development do ... end to include gems only in certain environments, like development or test.Click to reveal answer
Which command updates gems according to the Gemfile?
✗ Incorrect
bundle update updates gems to the latest versions allowed by the Gemfile. bundle install installs gems but does not update them if already installed.
What file locks the gem versions to ensure consistency?
✗ Incorrect
Gemfile.lock records the exact versions of gems installed, so all developers use the same versions.
How do you specify a gem only for the test environment?
✗ Incorrect
Using group :test do ... end wraps gems for that environment.
What does the '~>' operator mean in gem versioning?
✗ Incorrect
The '~>' operator means compatible with the specified version, allowing updates that do not change the leftmost digits.
Which command should you run after changing the Gemfile?
✗ Incorrect
After editing the Gemfile, run bundle install to install any new gems.
Explain how the Gemfile and Gemfile.lock work together to manage dependencies in a Rails project.
Think about how you keep everyone using the same tools in a team.
You got /4 concepts.
Describe how to include gems only for development or test environments in a Gemfile.
Imagine you want some tools only when coding or testing, not in production.
You got /3 concepts.