0

So far when learning Ruby and Ruby on Rails I keep encountering the syntax

ActionController::Base

And have never clarified exactly what it means. Why the :: instead of say, a slash? Wouldn't ActionController/Base be more specific?

For example, while using the Globalize3 gem I added to my model the line

class About < ActiveRecord::Base
  translates :message
end

I get the generated model named MonthlyPost::Translation, but that doesn't explain much. Where exactly are these stored, and what does the :: mean? Any thoughts would be wonderful. Thanks.

2 Answers 2

5

ActionController::Base means find the class Base in the module ActionController.

It's a way of organising your classes, and also to avoid conflicts with classes made by others.

Here is a good article explaining how to use Modules for namespaces.

Sign up to request clarification or add additional context in comments.

Comments

0

Rails is ruby. Learn ruby and your questions will be answered.

1 Comment

Thanks, I definitely agree. I'm currently reading the pickaxe ruby book, its a lot to learn so I try to ask more about certain topics im struggling with.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.