About requests and responses: class Actioncontroller::base < Metal

Source: Internet
Author: User
Tags object object

Extensions: Actioncontroller::base < Metal

2 Basic Themes:

    • Get and Show
    • Do and redirect
Requests

For each request, the Controller and action keys are determined by router. The remaining request parameters, the session, and all HTTP headers are made to the action via the request accessor method, and then the action is executed.

A full Request object can be used by the request accessor method. Used primarily for querying HTTP headers. For example:

def server_ip  location = request.env["REMOTE_ADDR"] render plain: "This server hosted at #{location}"end
Parameters

All request parameters, whether from the query string in the URL or the data submitted by the table through a POST request, can return a hash using the params method.

Example: An action is executed through the /post?category=all&limit=5. The params will include {"category" + "All", "Limit" = 5}

Example: Similar tables

<input type="text" name="post[name]" value="david"><input type="text" name="post[address]" value="hyacintvej">

After submission, the params will include {"POST" + + {"name" + "David", "Address" = "Hyacintvej"}}

Session

Response

Renders

Redirects

About requests and responses: class Actioncontroller::base < Metal

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.