Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there a built in way to rename an entire scaffold?

I'm using Rails 3.2, and have started with a scaffolding and built out from it, but have realized I need to rename the entire scaffold (Model, View, Controller, db:migrate, etc). Is there a built in way to do this, or should I just do it manually?

like image 584
azz Avatar asked Nov 02 '12 02:11

azz


1 Answers

I don't think there's anything rails provides to rename the name of models/controllers/views/tests etc. once they are created - whether as a part of a scaffold, or not.

You will have to change it manually.

If it is a brand new app that you have just started on, it might be easier to just delete the whole directory/drop the database, and start over again.

If not, you will have to go through the files created/modified by the scaffold generation, and modify them manually.

Make sure you either drop_and_recreate the relevant table, or add a migration to rename the table. See How do you write a migration to rename an ActiveRecord model and its table in Rails? for some relevant advice.

like image 51
Prakash Murthy Avatar answered Sep 23 '22 00:09

Prakash Murthy