It doesnβt mean that your controllers should subclass ApplicationController, but this is usually a standard, because the vast majority of rail applications use features layout(which may vary for each controller), so instead of forcing rare ones without layouts from expanding the layout ( layout nilor layout false) for each controller, they create an "abstract" that allows you to easily include controller functions for the entire application.
Now for models, you can create a ApplicationModelsubclass for all of your models, but there are two things to think about:
- ActiveRecord usually detects when you subclass already subclasses
ActiveRecord::Baseand uses this to enable STI (unidirectional table inheritance). ApplicationModel , , , . .
, abstract_class true ActiveRecord.
class ApplicationModel < ActiveRecord::Base
self.abstract_class = true
end
ActionController, abstract_class true, , , ApplicationModel. ApplicationController , .