tgandrews
tgandrews

Reputation: 12670

Gem installed and require but "Constant missing"

I have installed the gem 'simple_uuid' but nothing seems to be working.

Using irb and running the following:

require 'rubygems'
require 'simple_uuid'

is fine, both return true. But running the following:

// Class added by simple_uuid
UUID.new

returns

NameError: uninitialized constant UUID
    from (irb):3
    from :0

I'm a ruby newbie, so don't assume much in the answers. Thanks.

Upvotes: 2

Views: 1320

Answers (1)

duncan
duncan

Reputation: 6283

The class is inside a module SimpleUUID. So either do "include SimpleUUID" after the require, or refer to the class with the full namespace: SimpleUUID::UUID

require 'rubygems'
require 'simple_uuid'

> UUID.new
NameError: uninitialized constant UUID
        from (irb):3

> SimpleUUID::UUID.new
 => <UUID#70305762670060 time: Sat May 01 21:11:28 +0200 2010, usecs: 843284 jitter: 13605115058679102872> 

Upvotes: 3

Related Questions