问题
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