Practice - 5 Tasks
Answer the questions below
1fill in blank
easyComplete the code to install a gem using Bundler.
Ruby
system('bundle [1] rails')
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'bundle update' instead of 'bundle install' to add new gems.
✗ Incorrect
The bundle install command installs gems listed in the Gemfile.
2fill in blank
mediumComplete the code to specify a gem version in the Gemfile.
Ruby
gem 'nokogiri', '[1] 1.12.5'
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using '==' which locks to an exact version, limiting updates.
✗ Incorrect
The ~> operator specifies a version constraint allowing patch updates.
3fill in blank
hardFix the error in the Gemfile line to properly group gems for development and test.
Ruby
group :development[1] :test do gem 'rspec-rails' end
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using logical operators like 'and' or 'or' instead of commas.
✗ Incorrect
Use a comma to list multiple groups in the group method.
4fill in blank
hardFill both blanks to check if a gem is installed and print its version.
Ruby
if Gem::Specification.find_by_name('[1]') puts Gem::Specification.find_by_name('[2]').version end
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using different gem names in the two places causing errors.
✗ Incorrect
Use the gem name consistently to check and print its version.
5fill in blank
hardFill all three blanks to add a gem with a specific version and group it for development only.
Ruby
group :[1] do gem '[2]', '[3] 2.3.0' end
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Putting the gem in the wrong group or using wrong version operators.
✗ Incorrect
Group the gem 'rails' under development with version constraint '~> 2.3.0'.