Ruby on Rails Controller overview

Source: Internet
Author: User
Tags ruby on rails

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

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.