In an MVC based Web application, the application logic and the access to the data are accomplished by C, the controller, in MVC. Therefore, a deep understanding of the controller provided by the MVC framework is essential for developing an efficient, scalable, and stable application. ROR is no exception.
The controller provided in the ROR is called the Action Controller (Actioncontroller). This article will mainly discuss several services provided by the action controller and how to use the action controller.
What is an action controller
In Ror, the Action Pack is the core of the framework. It consists of two parts, an action view and an action controller. One feature of action packs is that they cannot be used in other types of programs except Web programs. Let's take a look at what happens when we type a URL through the browser, such as Http://localhost:3000/demo/say/hello. The following are steps for handling actions in ROR:
1. Ror first loaded the say_controller.rb file located in the App/controllers directory. This file is only loaded once.
2. Then Ror established the example of Class Saycontroller.
3. Once the Saycontroller class is instantiated, Ror looks for say_helper.rb files in App/helpers. If the file exists, it will be loaded and the file will be mixed with the Saycontroller object. This means that you can directly access the methods in the Sayhelper in the Saycontroller object.
4. Finally find the say.rb file in App/models, if present, load it.
So far, we've made the process of initializing the application very clear, so let's go ahead and look at the services provided by the action controller. The following is a list of services provided by ROR:
1. URL mapping
2. Session Tracking
3. Filtration and validation
4. Buffer