ruby rails

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实在是很方便。
原文地址:https://www.cnblogs.com/diegodu/p/5504944.html