MVC关系流程

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 and
LocalGlobalInstanceClassClass Names
name$debug@name@@totalPI
fishAndChips$CUSTOMER@point_1@@symtabFeetPerMile
x_axis$_@X@@NString
thx1138$plan9@_@@x_posMyClass
_26$Global@plan9@@SINGLEJazz_Song


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值