首页 > 其他 > 详细

ruby rails

时间:2016-05-18 14:31:49      阅读:181      评论:0      收藏:0      [点我收藏+]
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实在是很方便。

ruby rails

原文:http://www.cnblogs.com/diegodu/p/5504944.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!