Recall & Review
beginner
What is a Gemfile in a Ruby project?
A Gemfile is a file that lists all the Ruby gems (libraries) your project needs. It helps manage and install these dependencies easily.
Click to reveal answer
beginner
How do you specify a gem and its version in a Gemfile?
You write:
gem 'gem_name', '~> version_number'. For example, gem 'rails', '~> 7.0' means use Rails version 7.0 or compatible updates.Click to reveal answer
beginner
What command do you run to install gems listed in the Gemfile?
You run
bundle install. This reads the Gemfile and installs all the listed gems.Click to reveal answer
beginner
What is the purpose of the
source line in a Gemfile?The
source line tells Bundler where to find gems, usually https://rubygems.org, the main Ruby gem repository.Click to reveal answer
intermediate
How can you group gems for specific environments in a Gemfile?
You use
group :environment_name do ... end. For example, group :development do gem 'pry' end means the gem is only for development.Click to reveal answer
What does the command
bundle install do?✗ Incorrect
bundle install reads the Gemfile and installs all the gems your project needs.
How do you specify the source for gems in a Gemfile?
✗ Incorrect
The source line at the top of the Gemfile tells Bundler where to find gems.
Which syntax correctly adds the gem 'rails' version 7.0 or higher but less than 8.0?
✗ Incorrect
The ~> operator means compatible with version 7.0, but less than 8.0.
How do you add gems only for the development environment?
✗ Incorrect
Using group :development do ... end wraps gems for that environment.
What file does Bundler create to lock gem versions after installing?
✗ Incorrect
Bundler creates Gemfile.lock to record exact gem versions installed.
Explain the purpose of a Gemfile and how it helps manage project dependencies.
Think about how you tell your project what tools it needs.
You got /4 concepts.
Describe how to group gems for different environments in a Gemfile and why this is useful.
Consider when you want some tools only during development.
You got /4 concepts.