0
0
Ruby on Railsframework~5 mins

Gemfile and dependency management in Ruby on Rails - Cheat Sheet & Quick Revision

Choose your learning style9 modes available
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?
Abundle install
Bgem update
Cbundle update
Drails update
What file locks the gem versions to ensure consistency?
AGemfile
BGemfile.lock
Cgems.locked
Dbundle.lock
How do you specify a gem only for the test environment?
Agem 'rspec', env: :test
Bgem 'rspec', group: :test
Cgem 'rspec', only: :test
Dgroup :test do gem 'rspec' end
What does the '~>' operator mean in gem versioning?
ACompatible with this version, allowing patch updates
BAny version greater than this
CExactly this version
DLess than this version
Which command should you run after changing the Gemfile?
Abundle install
Brails server
Cgem install
Dbundle clean
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.