要直接回答您的问题ActionController
不是控制器类,它是为整个控制器堆栈提供动力的命名空间模块。在典型的Rails开发过程中,您不会与ActionController
模块进行交互。 ActionController::Base
实际上是控制器继承的类。这就是为什么你不能继承ActionController
。
但我认为这里有两个控制器。 ActionController::Base
和ApplicationController
。我想你可能错误ApplicationController
是ActionController
没有::Base
。
ActionController::Base
是主控制器类,其中所有的Rails功能都来自于此。 ApplicationController
是一个通用控制器,您可以将方法添加到并让所有其他Rails控制器继承。
你可以做以下的在控制器中的一个使用不同的布局:
class AuthenticationController < ApplicationController
layout 'authentication'
end
您可以直接使用AuthenticationController
,或有新的控制器从AuthenticationController
继承。