Delete or revert files created by the rails generator command

If you’re like me, youve occasionally made a typo when using the rails generator commands and ended up with a bunch of files that are misspelled. So, you just want to delete all the files that were just generated, aka revert the rails generate command.

Here’s how thats done

To preview the files that will be deleted, add the -p flag

rails d controller MyController -p
rails d model MyModel -p
rails d scaffold Stuff -p

To delete the generated files, run them without the -p flag

rails d controller MyController
rails d model MyModel
rails d scaffold Stuff

Ryan Sukale

Ryan is just a regular guy next door trying to manage his life and finances.

You may also like...