Linux command
rails-destroy 命令
文件
复制后可按需替换文件名、目录或参数。
常用示例
Remove model
rails destroy model [Name]
Remove controller
rails destroy controller [Name]
Remove scaffold
rails destroy scaffold [Name]
Remove migration
rails destroy migration [Name]
说明
rails destroy is the inverse of rails generate, removing all files and modifications that a generator previously created. It deletes model files, controllers, views, migrations, test files, and route entries that were scaffolded, cleanly undoing the generator's work without leaving orphaned code. The --pretend flag previews which files would be removed without actually deleting anything, allowing verification before committing to the operation. The command accepts the same generator names and arguments as rails generate, making it straightforward to reverse any previous scaffolding operation.
参数
- model _name_
- Remove model.
- controller _name_
- Remove controller.
- scaffold _name_
- Remove scaffold.
- migration _name_
- Remove migration.
- -p, --pretend
- Preview without removing.
FAQ
What is the rails-destroy command used for?
rails destroy is the inverse of rails generate, removing all files and modifications that a generator previously created. It deletes model files, controllers, views, migrations, test files, and route entries that were scaffolded, cleanly undoing the generator's work without leaving orphaned code. The --pretend flag previews which files would be removed without actually deleting anything, allowing verification before committing to the operation. The command accepts the same generator names and arguments as rails generate, making it straightforward to reverse any previous scaffolding operation.
How do I run a basic rails-destroy example?
Run `rails destroy model [Name]` in a terminal, then adjust file names, paths, flags, or remote targets for your system.
What does model _name_ do in rails-destroy?
Remove model.