菜单 学习猿地 - LMONKEY

VIP

开通学习猿地VIP

尊享10项VIP特权 持续新增

知识通关挑战

打卡带练!告别无效练习

接私单赚外块

VIP优先接,累计金额超百万

学习猿地私房课免费学

大厂实战课仅对VIP开放

你的一对一导师

每月可免费咨询大牛30次

领取更多软件工程师实用特权

入驻
192
0

ruby rails

原创
05/13 14:22
阅读数 69431
http://www.zhihu.com/question/19552402
 
作者:陈振宇
链接:http://www.zhihu.com/question/19552402/answer/12367336
来源:知乎
著作权归作者所有。商业转载请联系作者获得授权,非商业转载请注明出处。

先搞懂Rails的路由模式
posts GET /posts(.:format) {:controller= > "posts", :action= > "index"}
POST /posts(.:format) {:controller= > "posts", :action= > "create"}
new_post GET /posts/new(.:format) {:controller= > "posts", :action= > "new"}
edit_post GET /posts/:id/edit(.:format) {:controller= > "posts", :action= > "edit"}
post GET /posts/:id(.:format) {:controller= > "posts", :action= > "show"}
PUT /posts/:id(.:format) {:controller= > "posts", :action= > "update"}
DELETE /posts/:id(.:format) {:controller= > "posts", :action= > "destroy"}
通过rake routes你可以得到类似上面的路由记录,这样你就明白rails是如何通过路由来调用MVC里的C-controller里的方法了;
然后再看看MVC里的M-model还有数据库迁移部分,剩下就是V-view了,重点是如何和javascript打交道的,Rails3和之前的版本都有不同。
完成了这些就算入门了,然后就是逛github和这样的网站,了解下各个方面的插件。ps: Bundler实在是很方便。

发表评论

0/200
192 点赞
0 评论
收藏