Search code examples
ruby-on-railsruby-on-rails-3ruby-on-rails-3.1

Rails controller inheritance


Say I have controller X which inherits from controller Y:

class X < YController

and my YController inherits from ApplicationController.

Would I still have access to all methods/classes via my X controller that are available in the ApplicationController?


Solution

  • Yes, you will. All methods will be inherited unless you override them in the child controller. Remember that Rails controllers are just Ruby classes and you will get the same inheritance behavior that you get with any other Ruby class.