Bird
0
0

Which of these lines correctly adds the gem 'devise' with any version in a Gemfile?

easy📝 Conceptual Q2 of 15
Ruby - Gems and Bundler
Which of these lines correctly adds the gem 'devise' with any version in a Gemfile?
Agem 'devise', '~> 4.7.3'
Bgem 'devise'
Cgem 'devise', version: '4.7.3'
Dgem 'devise' version '4.7.3'
Step-by-Step Solution
Solution:
  1. Step 1: Identify correct syntax for gem without version

    To add a gem with any version, just write gem 'devise' without extra parameters.
  2. Step 2: Check other options for syntax errors

    gem 'devise', '~> 4.7.3' specifies a version constraint, not any version. Options C and D have incorrect syntax.
  3. Final Answer:

    gem 'devise' -> Option B
  4. Quick Check:

    Gemfile gem line without version = gem 'name' [OK]
Quick Trick: No version means just gem 'name' [OK]
Common Mistakes:
  • Using wrong syntax for version constraints
  • Adding extra keywords like 'version:' incorrectly
  • Missing commas or quotes

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Ruby Quizzes