ruby-on-railsrubydestroyundo

How to Undo a rails destroy controller?


I was trying to delete two pages from my files (pages/about & pages/contact) and I used the terminal line:

rails destroy controller pages about contact

This command did delete them, but it also deleted my entire app/views/pages folder which included the home page and more! Unfortunately I did not upload to github.

Is there a way to undo a "Rails destroy" and recover the lost files?


Solution

  • Once controller is destroyed using rails destroy controller ... command, it can't be undone.

    Be sure that you've version controlled your code using git or similar VCS tools. If your code is on git then you can easily get all deleted files back.

    git checkout app/controllers/pages_controller.rb