Question

I'm new to RoR and I'm following Michael Hartl's tutorial (so feel free to correct the terminology I'm using where you see it fit). In chapter 2, I created a Users table by running these lines:

$ rails generate scaffold User name:string email:string
$ bundle exec rake db:migrate

Then, I ran the code below to try to create a Microposts table (However, I misspelled Micropost without an 'r'!)...

$ rails generate scaffold Miropost content:string user_id:integer
$ bundle exec rake db:migrate

Now I want to delete the Miropost table I created. After searching in stackoverflow.com, I understand I can undo the database migration (ie., db:migrate) by running rake db:migrate:reset. My question is would I need to undo the "rails generate scaffold" too? And when do scaffolds cease to exist?

Was it helpful?

Solution

First you would need to rollback the changes from db. Assuming that the migration generated for Miropost is the latest migration in your db.

Just run

rake db:rollback ## This will drop the table miroposts

After this destroy the existing scaffold by :

rails destroy scaffold Miropost content:string user_id:integer

Then all you need to do is to recreate the scaffold with correct spelling and run rake db:migrate

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top