Bird
0
0

Which of the following is the correct way to specify a gem in a Gemfile?

easy📝 Syntax Q12 of 15
Ruby - Gems and Bundler
Which of the following is the correct way to specify a gem in a Gemfile?
Ainstall gem rails version 7.0
Brequire 'rails', version: '7.0'
Cgem 'rails', '~> 7.0'
Dadd gem rails 7.0
Step-by-Step Solution
Solution:
  1. Step 1: Recall Gemfile syntax

    In a Gemfile, gems are declared using the gem method with the name and version string.
  2. Step 2: Match correct syntax

    gem 'rails', '~> 7.0' uses gem 'name', 'version' format which is correct.
  3. Final Answer:

    gem 'rails', '~> 7.0' -> Option C
  4. Quick Check:

    Gemfile gem syntax = gem 'name', 'version' [OK]
Quick Trick: Gemfile uses gem 'name', 'version' format [OK]
Common Mistakes:
  • Using commands like install or add inside Gemfile
  • Using require instead of gem in Gemfile
  • Incorrect version syntax

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Ruby Quizzes