Forum: Ruby on Rails RubyGem loading into a controller (High quality question)

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
Bb4bdf2b184027bc38d4fb529770cde5?d=identicon&s=25 Wes Gamble (weyus)
on 2006-03-23 00:19
INSTALLATION:

Ruby 1.8.2
Rails 1.0.0
rubyful_soup 1.0.4 (GEM)

FACTS:
0) I have successfully installed the rubyful_soup GEM using (I had
previously installed it, which is why the output may look sparse):

C:\ruby>gem install -r rubyful_soup
Attempting remote installation of 'rubyful_soup'
Successfully installed rubyful_soup-1.0.4
Installing RDoc documentation for rubyful_soup-1.0.4...

1) I have a controller.  The first 4 lines are:

require 'rubygems'
require_gem 'rubyful_soup', '>= 1.0.4'

class ESimplyController < ApplicationController

2) In this controller I have a method.  Here it is:

public
def index
  parser = BeautifulSoup.new(String.new "test")    #Establish the parse
tree
end

When I execute this action, I get:

  "uninitialized constant BeautifulSoup"

which basically tells me that the BeautifulSoup class within the
rubyful_soup.rb file can't be seen.

3) Inside of the rubyful_soup.rb file, the BeautifulSoup class is
defined, like so:

class BeautifulSoup < BeautifulStoneSoup
....

QUESTION 1: Have I correctly included this RubyGem?

QUESTION 2: Does something else need to be done to successfully export
the BeautifulSoup class name so that it's accessible?

QUESTION 3: Does something else need to be done to successfully import
the BeautifulSoup class name so that it's accessible?

Thanks for any help that you can provide.  I am at my wit's end.

To top it all off, at random times and under circumstances that I am
unable to recreate, this was totally working for me.  I do not
understand what is wrong.

Thanks,
Wes
Bb4bdf2b184027bc38d4fb529770cde5?d=identicon&s=25 Wes Gamble (weyus)
on 2006-03-23 00:42
There appears to be a time component to my problem.  If I leave my
WEBrick server up for a few minutes (maybe 5 maybe 10 I'm not sure), all
of a sudden it can find the GEM and everything works.

Perhaps there is some kind of caching going on with autoloading of
classes???

Wes Gamble wrote:
> INSTALLATION:
>
> Ruby 1.8.2
> Rails 1.0.0
> rubyful_soup 1.0.4 (GEM)
>
...
Bb4bdf2b184027bc38d4fb529770cde5?d=identicon&s=25 Wes Gamble (weyus)
on 2006-03-23 18:47
SOLUTION:

Apparently

require_gem

doesn't actually require anything, it just enforces the versioning
rules.

So I needed to do

require 'rubygems'
require 'rubyful_soup'
require_gem 'rubyful_soup', '>= 1.0.4'

WG

Wes Gamble wrote:
> There appears to be a time component to my problem.  If I leave my
> WEBrick server up for a few minutes (maybe 5 maybe 10 I'm not sure), all
> of a sudden it can find the GEM and everything works.
>
> Perhaps there is some kind of caching going on with autoloading of
> classes???
>
> Wes Gamble wrote:
>> INSTALLATION:
>>
>> Ruby 1.8.2
>> Rails 1.0.0
>> rubyful_soup 1.0.4 (GEM)
>>
> ...
This topic is locked and can not be replied to.