Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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.

like image 842
Ibrahim Muhammad Avatar asked Mar 12 '12 19:03

Ibrahim Muhammad


People also ask

How do I create a scaffold in rails?

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.


2 Answers

You can use rails g resource Foo bar:text

like image 112
drexin Avatar answered Sep 18 '22 21:09

drexin


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.

like image 22
Rick Smith Avatar answered Sep 20 '22 21:09

Rick Smith