Reputation: 105217
After its initial construction, I have added a couple of columns to my Books
database table. As I actually want my views to reflect and show the fields related to all these new added columns I figured it'd be cheaper to just delete everything that's inside the views/books/
folder, and have some scaffold code regenerate it from the ground up. I don't want to delete either the controller or the model file, as both already contain some logic I'd like to keep. I'm fine editing those files myself on a on-need basis.
How to accomplish the task?
From https://stackoverflow.com/a/4333530/130758 I can see scaffold
seems to have options for both controllers and models, but unfortunately, not for views. Am I bound to have to do this grunt work by myself? I'm aware I can just create a new git branch, delete the + model + views and regenerate all of them, copy paste the the views back into the original branch and I'm ready to go, but I'd prefer a more scientific approach, whenever possible.
Thanks
Upvotes: 25
Views: 10821
Reputation: 6352
I know this question is probably too old to help the person who originally asked the question, but I'd like to point out that the default scaffold
generator calls the erb:scaffold
generator to generate the ERB files. So, you can do:
rails g erb:scaffold Book
This will return:
create app/views/books
create app/views/books/index.html.erb
create app/views/books/edit.html.erb
create app/views/books/show.html.erb
create app/views/books/new.html.erb
create app/views/books/_form.html.erb
Upvotes: 83