Is there a way to generate a rails scaffold without the views?

荒凉一梦 提交于 2020-03-17 04:09:57

问题


Is there a way to generate a rails scaffold without the views, there has to be a better way then generating the scaffold and deleting the views and the view specs.


回答1:


You can use rails g resource Foo bar:text




回答2:


If you would like to have the controllers generated in the normal fashion, try this:

rails g resource Foo bar:text
rails g scaffold_controller Foo --skip-template-engine

The first command generates the model and the second one uses the generated model to create the controller which includes the RESTful actions.

--skip-template-engine causes the views to be omitted.




回答3:


Not sure why these answers create the resource first when you can just generate the entire scaffold without the views but still get your controller methods and model.

rails g scaffold Foo bar:string --skip-template-engine


来源:https://stackoverflow.com/questions/9673484/is-there-a-way-to-generate-a-rails-scaffold-without-the-views

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