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.
To generate a fully working scaffold for a new object, including model, controller, views, assets, and tests, use the rails g scaffold command. Then you can run rake db:migrate to set up the database table. Then you can visit http://localhost:3000/widgets and you'll see a fully functional CRUD scaffold.
You can use rails g resource Foo bar:text
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With