Require A Specific Version Of A Gem
Join the DZone community and get the full member experience.Join For Free
If you want to require a specific version of a gem you have to both specify the version using the gem method AND require the gem as you normally do. If you don't do this you will receive an error like "NameError: uninitialized constant RestClient". Some gems make this more complex by having a gem name that is not the same as the name of the file you then have to require like in the example below.
#!/usr/bin/env ruby -rubygems gem 'rest-client', '= 1.5.0' #Install with: sudo gem install rest-client -v 1.5.0 require 'rest_client' puts RestClient.get("http://example.com").body