Tag: action

Rails – map.resources的冗余RESTFUL操作? (新的,创造)

我想知道为什么当你使用map.resources在rails中创建restful路由时,它会生成新的,创建,编辑,更新的操作 ? 在为创建和更新声明一个动作并执行类似的操作时有什么不对吗? def create unless post? @user = User.new else redirect_to :action => ‘index’ if user.create(params[:user]) end end 所以我们可以有类似的东西 :GET users/create # to show the form (same as action – new) :POST users/create # to create a new user 由于Restful基于动词,这不是最好的使用方法吗? 感谢您的关注