[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

Re: Odd requirement behavior between two environments

Ian Whitney

7/16/2007 7:25:00 PM


On 7/16/07 2:05 PM, "Gregory Brown" <gregory.t.brown@gmail.com> wrote:

> On 7/16/07, Ian Whitney <iwhitney@ssa-i.org> wrote:
>
>> Ok, so that looks good. I can require the gem & then IRB knows what
>> ActiveRecord is. Great.
>>
>> New development machine where this doesn't work
>> Ruby 1.8.6
>> Gems 0.9.4
>> ActiveRecord gem installed 1.15.3
>>
>> Results of IRB session on the new development machine
>>
>> irb(main):001:0> require 'rubygems'
>> => true
>> irb(main):002:0> gem 'activerecord'
>> => true
>> irb(main):003:0> ActiveRecord
>> NameError: uninitialized constant ActiveRecord
>> from (irb):3
>>
>> So, something is up. In line 2 I'm using the command newer command 'gem'
>> instead of the depreciated 'require_gem'. But I get the same result even if
>> I use the depreciated command.
>>
>> Any ideas? Something I forgot to install on this new machine? Or some weird
>> configuration change I made on the old machine that I didn't copy over.
>
> require_gem / gem are not the same as require. They're meant for
> locking gems to specific versions or making sure they exist, not
> loading libraries, e.g.
>
> gem "ruport", "=1.0.1"
>
> Also, with that in mind note that gem names don't always coincide with
> library names, so you actually will need to do this:
>
> require "rubygems"
> require "active_record"
>
> In earlier versions of RubyGems, it was possible for the require_gem
> command to autoload libraries, this is no longer the case.
>
> Hope that helps...
>
> -greg
>

Thank you, that seems to have moved me forward.

Ian