Delete or revert files created by the rails generator command

If you’re like me, youve occa­sion­ally made a typo when using the rails gen­er­a­tor com­mands and ended up with a bunch of files that are mis­spelled. So, you just want to delete all the files that were just gen­er­ated, aka revert the rails gen­er­ate command.

Here’s how thats done

To pre­view 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 gen­er­ated files, run them with­out 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...