Wes Gamble
2006-Mar-22 23:19 UTC
[Rails] RubyGem loading into a controller (High quality question)
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 -- Posted via http://www.ruby-forum.com/.
Wes Gamble
2006-Mar-22 23:43 UTC
[Rails] Re: RubyGem loading into a controller (High quality question
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) >... -- Posted via http://www.ruby-forum.com/.
Wes Gamble
2006-Mar-23 17:47 UTC
[Rails] Re: RubyGem loading into a controller (High quality question
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) >> > ...-- Posted via http://www.ruby-forum.com/.