0

I am new to Ruby on Rails Development and was trying to understand inheritance in Rails, I understood how do a class inherit from a parent class

For Example MyController < ActionController, in this Action Controller is the parent class. But I dont understand this syntax

ApplicationController < ActionController::Base

Specifically what is the purpose of ::Base

7
  • Code tends to be organised into Classes or Modules. Classes follow inheritance rules, and can be instantiated into instances, whereas modules are more like a simple collection of code. Sometimes classes are collected into modules to achieve the namespacing Marek refers to: that is the case here: "ActionController" is a module and "Base" is a class inside that module (the class that your app controllers inherit from). Commented Aug 5, 2014 at 13:09
  • thanks a lot Max for providing the detailed information... Commented Aug 5, 2014 at 13:14
  • Btw, it's informative to look through the codebase. have a look in your gems folder for the ActionController module. Commented Aug 5, 2014 at 13:16
  • can you please let me know where will this gems folder will be located and in which gem ActionController module is there? Commented Aug 5, 2014 at 13:19
  • No I am not using rvm Commented Aug 5, 2014 at 14:20

1 Answer 1

2

This syntax is used to indicate that Base is a class inside of ActionController namespace.

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

Comments

Your Answer

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