Can 'rails g controller' generate restful routes?

杀马特。学长 韩版系。学妹 提交于 2019-12-06 07:18:34

问题


Is there a way, using rails generators, to create a controller with RESTful routes?

Generating a controller and specifying the action name creates a controller and adds a route to config/routes.rb, but create is a get:

$ rails g controller foos new create
  create  app/controllers/foos_controller.rb
   route  get "foos/create"
   ...

I'd prefer to see route post "foos", but don't see anything useful in rails g controller --help


回答1:


Try using rails generate scaffold_controller Foos



来源:https://stackoverflow.com/questions/12978447/can-rails-g-controller-generate-restful-routes

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!