Platinum Partner

Require A Specific Version Of A Gem

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
{{ tag }}, {{tag}},

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}
{{ parent.authors[0].realName || parent.author}}

{{ parent.authors[0].tagline || parent.tagline }}

{{ parent.views }} ViewsClicks
Tweet

{{parent.nComments}}