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