3-1 Rails 运作原理
这里我开始看不懂了,可以解说一下整个网站的运作原理吗?
Rails 是这样运作的:
- 使用者对网站做“请求”,然后网站会先去解析
config/routes.rb
- 然后发现网址是
http://localhosts:3000/groups
,它就会去找groups
controller 下的index
action(为什么是去找 index action),我们在后面的章节会解释。 - Controller 你可以想像成“控制台”,Controller 里面去读出
Group.all
,意思是捞出“所有的群”,并指定到@groups
,这是一个变数。 @groups
这个变数,是供app/views/groups/index.html.erb
使用。View 会根据语法画出整张表格。
Updated less than a minute ago