Hello,
My ruby cannot find a class from the actionpack gem:
require ‘rubygems’
require ‘actionpack’
ActionController::Session::AbstractStore
=> uninitialized constant ActionController (NameError)
Directly adding the code works, though:
require ‘actionpack’
load
“/var/lib/gems/1.8/gems/actionpack-2.3.4/lib/action_controller/session/abstract_store.rb”
ActionController::Session::AbstractStore
=> no error.
This problem occurs when I try to require dm-core, which needs
rails_datamapper, which uses the AbstractStore Class.
Thanks for your help
Martin Gütlein wrote:
Hello,
My ruby cannot find a class from the actionpack gem:
Rails questions are best asked on a Rails mailing list. This list is for
Ruby (the programming language). A smart question would also say what
exact version of Rails you are using, and on what platform.
But I would make the following comment: require ‘foo’ doesn’t
necessarily load everything inside the ‘foo’ package. It loads exactly
what foo.rb tells it to load. You will need to look at the source of
foo.rb to see if it loads what you want, and if it doesn’t, you’ll need
to load what you want yourself.
require ‘rubygems’
=> true
require ‘actionpack’
=> true
ActionController::Session::AbstractStore
NameError: uninitialized constant ActionController
from (irb):3
require ‘action_controller’
=> true
ActionController::Session::AbstractStore
=> ActionController::Session::AbstractStore
[This is with rails-2.3.2 under Ubuntu Hardy with ruby-1.8.6p111
compiled from source]
And you can see why easily:
$ cat /usr/lib/ruby/gems/1.8/gems/actionpack-2.3.2/lib/actionpack.rb
require ‘action_pack’
$ cat /usr/lib/ruby/gems/1.8/gems/actionpack-2.3.2/lib/action_pack.rb
<< snip copyright message >>
require ‘action_pack/version’
$ cat
/usr/lib/ruby/gems/1.8/gems/actionpack-2.3.2/lib/action_pack/version.rb
module ActionPack #:nodoc:
module VERSION #:nodoc:
MAJOR = 2
MINOR = 3
TINY = 2
STRING = [MAJOR, MINOR, TINY].join('.')
end
end
So if you require ‘actionpack’, that’s exactly all you will get.