简体   繁体   中英

What is purpose of ApplicationController class in ruby

I was reading rails guide and I found every controller class is defined to inherit from ApplicationController class

I am looking for a proper explanation about this class and what it does.

With AppllicationController in place you won't need to configure application wide settings in each controller; you can configure them in ApplicationController and they will be available to all controllers that inherit from it.

From the docs :

By default, only the ApplicationController in a Rails application inherits from ActionController::Base . All other controllers inherit from ApplicationController. This gives you one class to configure things such as request forgery protection and filtering of sensitive request parameters.

Exactly what it says, and what you quote in the question.

Anything you put in ApplicationController will be inherited by every other controller class you create (assuming you define the class correctly).

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM