![Forrest logo](/images/logo.png)
rails-destroy:tldr:9b66b
The rails destroy
command in Ruby on Rails is used to generate and run destroy scripts for a specific Rails component or feature. This command reverses the changes made by the corresponding rails generate
command. It is commonly used to remove previously generated files, classes, migrations, or other components associated with a Rails application. Here's an example usage: rails generate model User name:string email:string
In the above command, a model named User with name and email attributes is generated. To reverse this generation and destroy the User model and its associated files, you can use the rails destroy
command: rails destroy model User
This will remove the User model file, its corresponding migration file, and any other associated files, effectively undoing the previous generation. The rails destroy
command can be used with other Rails components like controller, scaffold, migration, helper, etc., to reverse their respective generations and remove their associated files.