Topic: ActionController::Base

If I have a code like this:

class myClass < ActionController::Base
Some code
end

What does the :: signify?  I have tried to find reference for this in my Agile Development book, but I can't find anything.

I'm also presuming that the < means that the class myClass inherits from ActionController::Base, I just don't understand the ::

Re: ActionController::Base

The :: signifies that Base is a class inside the ActionController module. In Rails, classes are grouped inside modules to give them a namespace. This way there can be other classes called "Base" in other modules and there won't be any conflict.

Railscasts - Free Ruby on Rails Screencasts

Re: ActionController::Base

Actually shouldn't it be ActiveRecord::Base?

Re: ActionController::Base

NickToye wrote:

Actually shouldn't it be ActiveRecord::Base?

That depends. If your class above is a model, then yes it should be ActiveRecord::Base.

In a typical app, the ApplicationController will be the only controller that inherits from ActionController::Base. All other controllers will inherit from ApplicationController instead, like so:

class PicturesController < ApplicationController
  def index
    ...
  end
end

vinnie - rails forum admin

Re: ActionController::Base

ok I think i'm getting it.

So to reiterate, the double colon means that the keyword following it is a class that is exclusive to the keyword preceeding the double colon.

Re: ActionController::Base

Roughly, yes. It can also be multiple modules deep:

class Klass < Foo::Bar::Blah
end

If you get a good Ruby book (not Rails specific) it should go into detail on modules.

Railscasts - Free Ruby on Rails Screencasts

Re: ActionController::Base

i've been on the ruby site and it was interesting.