I have what appears to be a problem accessing methods from within an
application. I can access them from irb, but not from within the
app. In other words:
irb(main):001:0> require 'rubygems'
=> true
irb(main):002:0> require 'haml'
=> true
irb(main):003:0> Haml.respond_to?('init_rails')
=> true
irb(main):004:0>
But in the app, similar code gives an ‘undefined method’ error.
begin
require File.join(File.dirname(__FILE__), 'lib', 'haml') # From
here
rescue LoadError
require ‘haml’ # From gem
end
Haml.init_rails(binding)
undefined method `init_rails’ for Haml:Module (NoMethodError)
The only thing that makes sense to me is that somewhere in the app the
gem path is overridden or isn’t being picked up properly. Any
suggestions would be greatly appreciated- this one is driving me
bonkers. I don’t think it has anything to do with haml-- I think it
has to do with the application reading the gems-- but I could be
wrong.
Some more details:
rails --version
Rails 2.1.0
gem env:
RubyGems Environment:
- RUBYGEMS VERSION: 1.2.0
- RUBY VERSION: 1.8.7 (2008-06-20 patchlevel 22) [i686-darwin9.3.0]
- INSTALLATION DIRECTORY: /usr/local/lib/ruby/gems/1.8
- RUBY EXECUTABLE: /usr/local/bin/ruby
- EXECUTABLE DIRECTORY: /usr/local/bin
- RUBYGEMS PLATFORMS:
- ruby
- x86-darwin-9
- GEM PATHS:
- /usr/local/lib/ruby/gems/1.8 [this is correct]
- GEM CONFIGURATION:
- :update_sources => true
- :verbose => true
- :benchmark => false
- :backtrace => false
- :bulk_threshold => 1000
- :sources => [“http://gems.rubyforge.org”, “http://
gems.datamapper.org”]
- REMOTE SOURCES: