# How to Undo Generate Scaffold Command in Rails

*Published on November 13, 2022*

---


TL;DR: Run the bin/rails destroy scaffold Post to undo the changes made by scaffold command in Rails. If you had applied the generated migration, don't forget to rollback the migration using bin/rails db:rollback command first.

The&nbsp;`rails generate scaffold`&nbsp;command in Rails provides a quick and easy way to generate the major building pieces for your Rails app. It will generate the MVC (model, view, and controller) parts for your domain along with CRUD support. All in a single command.

For example, if you want to generate the basic CRUD functionality for the&nbsp;`Post`&nbsp;model in your Rails blog, run the following scaffold command.

```bash
$ bin/rails generate scaffold Post name:string content:text
```

Rails will create a bunch of new folders and files in your application, and also edit the&nbsp;`config/routes.rb`.

**What if you made a mistake?**&nbsp;Don't worry. Rails provides a simple way to undo the scaffold.

## How to Undo Rails Scaffold Command

Simply run the following command:

```bash
$ bin/rails destroy scaffold Post
```

This will delete the files created by the scaffolding process.

If you had applied the migration generated by the scaffold, first rollback it using the&nbsp;`db:rollback`&nbsp;command, and then destroy the migration.

```bash
$ bin/rails db:rollback
$ bin/rails destroy scaffold Post
```

Also remember that the&nbsp;`destroy scaffold`&nbsp;command won't undo any other changes you made after generating the scaffold. So keep in mind to undo them all if needed.

In fact, you can use the&nbsp;`destroy`&nbsp;command to undo any&nbsp;`generate`&nbsp;command in Rails. For example, if you generated a helper using

```bash
$ bin/rails generate helper Payment
```

You can undo it using this command:

```bash
$ bin/rails destroy helper Payment
```

Hope that helps.

