Leem.fin
Leem.fin

Reputation: 42582

how to revert back after generate an controller

I am using Rails v2.3.2

I generate a controller by:

script/generate controller cars

It will create many directories and files:

  exists  app/controllers/
  exists  app/helpers/
  create  app/views/cars
  create  test/functional/
  create  test/unit/helpers/
  create  app/controllers/cars_controller.rb
  create  test/functional/cars_controller_test.rb
  create  app/helpers/cars_helper.rb
  create  test/unit/helpers/cars_helper_test.rb

Two questions:

1. How can I revert this command back?(What is the command to revert it back)?

2 What is the command if I only want to generate app/controllers/cars_controller.rb without other files and directories been generated?

Upvotes: 2

Views: 178

Answers (4)

Igbanam
Igbanam

Reputation: 6082

Two answers

  1. script/destroy controller cars #rails 2
  2. script/generate controller -T --[skip|no]-views --[skip|no]-helper

Where you can use either skip or no as a prefix

Upvotes: 0

Hishalv
Hishalv

Reputation: 3052

try

 rails destroy controller cars or script/destroy controller cars

and for models

rails destroy model blahblah

if you want to generate without test files try using this option

script/generate controller cars -T

and if you want to leave out helper files follow this tutorial

Upvotes: 0

mliebelt
mliebelt

Reputation: 15525

Another solution could be:

  • Ensure that you have a version management in place (Git, Subversion, anything working).
  • Ensure that you have an updated current working copy, with no pending changes.
  • Then you can revert your changes by using your version management. In Subversion, you would just call svn revert . in the Rails application root directory.

Upvotes: 2

rdsoze
rdsoze

Reputation: 1768

Either should work

    rails destroy controller cars  #rails 3

    script/destroy controller cars #rails 2

And if you want to just create a controller file, you might as well create a new file and rename it to cars_controller.rb .

Upvotes: 2

Related Questions