MVC关系流程

来源:互联网 发布:深圳找工作知乎 编辑:程序博客网 时间:2024/06/05 17:06

mvc_detailed

http://ruby.railstutorial.org/chapters/a-demo-app.html?version=3.2#sec-planning_the_application

1.The browser issues a request for the /users URI.

2.Rails routes /users to the index action in the Users controller.
3.The index action asks the User model to retrieve all users (User.all).
4.The User model pulls all the users from the database.
5.The User model returns the list of users to the controller.
6.The controller captures the users in the @users variable, which is passed to the indexview.
7.The view uses embedded Ruby to render the page as HTML.

8.The controller passes the HTML back to the browser.3

         We start with a request issued from the browser—i.e., the result of typing a URI in the address bar or clicking on a link (Step 1 in Figure 2.11). This request hits the Rails router (Step 2), which dispatches to the proper controller action based on the URI (and, as we’ll see in Box 3.2, the type of request). The code to create the mapping of user URIs to controller actions for the Users resource appears in Listing 2.2; this code effectively sets up the table of URI/action pairs seen in Table 2.1. (The strange notation :users is a symbol, which we’ll learn about in Section 4.3.3.)

Example variable and class names
VariablesConstants andLocalGlobalInstanceClassClass Namesname$debug@name@@totalPIfishAndChips$CUSTOMER@point_1@@symtabFeetPerMilex_axis$_@X@@NStringthx1138$plan9@_@@x_posMyClass_26$Global@plan9@@SINGLEJazz_Song


原创粉丝点击