Topic: uninitialized constant ActionView::Helpers::TagHelper::ERB (NameError)

Hello, I am new to ruby and trying to refactor some ruby code that just consists of a few files containing a couple of small classes and am running rspec on a specification file like "rspec collector_specs.rb" and am getting the following error output:

C:/Ruby191/lib/ruby/gems/1.9.1/gems/actionpack-3.0.3/lib/action_view/helpers/tag_helper.rb:10:in `<module:TagHelper>': u
ninitialized constant ActionView::Helpers::TagHelper::ERB (NameError)
        from C:/Ruby191/lib/ruby/gems/1.9.1/gems/actionpack-3.0.3/lib/action_view/helpers/tag_helper.rb:9:in `<module:He
lpers>'
        from C:/Ruby191/lib/ruby/gems/1.9.1/gems/actionpack-3.0.3/lib/action_view/helpers/tag_helper.rb:6:in `<module:Ac
tionView>'
        from C:/Ruby191/lib/ruby/gems/1.9.1/gems/actionpack-3.0.3/lib/action_view/helpers/tag_helper.rb:4:in `<top (requ
ired)>'
        from C:/Ruby191/lib/ruby/gems/1.9.1/gems/actionpack-3.0.3/lib/action_view/helpers/javascript_helper.rb:1:in `req
uire'
        from C:/Ruby191/lib/ruby/gems/1.9.1/gems/actionpack-3.0.3/lib/action_view/helpers/javascript_helper.rb:1:in `<to
p (required)>'
        from C:/Ruby191/lib/ruby/gems/1.9.1/gems/actionpack-3.0.3/lib/action_view/helpers/url_helper.rb:1:in `require'
        from C:/Ruby191/lib/ruby/gems/1.9.1/gems/actionpack-3.0.3/lib/action_view/helpers/url_helper.rb:1:in `<top (requ
ired)>'
        from C:/Ruby191/lib/ruby/gems/1.9.1/gems/actionpack-3.0.3/lib/action_view/helpers/asset_tag_helper.rb:3:in `requ
ire'
        from C:/Ruby191/lib/ruby/gems/1.9.1/gems/actionpack-3.0.3/lib/action_view/helpers/asset_tag_helper.rb:3:in `<top
 (required)>'
        from C:/refactored/app/collector.rb:2:in `require'
        from C:/refactored/app/collector.rb:2:in `<top (required)>'
        from C:/refactored/app/collector_specs.rb:8:in `require'
        from C:/refactored/app/collector_specs.rb:8:in `<top (required)>'
        from C:/Ruby191/lib/ruby/gems/1.9.1/gems/rspec-core-2.4.0/lib/rspec/core/configuration.rb:387:in `load'
        from C:/Ruby191/lib/ruby/gems/1.9.1/gems/rspec-core-2.4.0/lib/rspec/core/configuration.rb:387:in `block in load_
spec_files'
        from C:/Ruby191/lib/ruby/gems/1.9.1/gems/rspec-core-2.4.0/lib/rspec/core/configuration.rb:387:in `map'
        from C:/Ruby191/lib/ruby/gems/1.9.1/gems/rspec-core-2.4.0/lib/rspec/core/configuration.rb:387:in `load_spec_file
s'
        from C:/Ruby191/lib/ruby/gems/1.9.1/gems/rspec-core-2.4.0/lib/rspec/core/command_line.rb:18:in `run'
        from C:/Ruby191/lib/ruby/gems/1.9.1/gems/rspec-core-2.4.0/lib/rspec/core/runner.rb:55:in `run_in_process'
        from C:/Ruby191/lib/ruby/gems/1.9.1/gems/rspec-core-2.4.0/lib/rspec/core/runner.rb:46:in `run'
        from C:/Ruby191/lib/ruby/gems/1.9.1/gems/rspec-core-2.4.0/lib/rspec/core/runner.rb:10:in `block in autorun'

Does anyone know what is causing this error and how I can eliminate it?  The code referencing actionview modules is:

require 'rubygems'
require 'action_view/helpers/asset_tag_helper'
require 'action_view/helpers/tag_helper'
require 'erb'

class Collector

  include ActionView::Helpers::TagHelper
  include ActionView::Helpers::AssetTagHelper

  def self.foo
    "foo"
  end

  def display(profile, size, html = {}, options = {}, link = true)
    
    ... unrelated code here ...
    
    return image_tag("default.png")
  end

end

I am just starting out with ruby programming and have a lot to learn, so any and all help and input is most appreciated.

Re: uninitialized constant ActionView::Helpers::TagHelper::ERB (NameError)

Its probably a Rails 3 change. I ran into something similar today. Its because Rails 3 doesn't read the lib directory by default on load anymore.

I ended up having to add this line to the application.rb file inside the Class definition. This is straight form the Lighthouse ticket. You can google for it a bit to find the exact article.

config.autoload_paths << File.join(config.root, "lib")

Good Luck!
Dave

"If I'd asked my customers what they wanted, they'd have said a faster horse." - Henry Ford