uninitialized constant ActionController (NameError)

M

Martin Gütlein

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
 
B

Brian Candler

Martin said:
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.
NameError: uninitialized constant ActionController
from (irb):3
[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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,578
Members
45,052
Latest member
LucyCarper

Latest Threads

Top