“rails g controller"可以生成宁静的路线吗? [英] Can 'rails g controller' generate restful routes?
本文介绍了“rails g controller"可以生成宁静的路线吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
有没有办法使用 Rails 生成器来创建具有 RESTful 路由的控制器?
Is there a way, using rails generators, to create a controller with RESTful routes?
生成控制器并指定动作名称创建控制器并向config/routes.rb
添加路由,但create
是get
>:
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"
...
我更希望看到 route post "foos"
,但在 rails g controller --help
I'd prefer to see route post "foos"
, but don't see anything useful in rails g controller --help
推荐答案
尝试使用 rails generate scaffold_controller Foos
这篇关于“rails g controller"可以生成宁静的路线吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文