Reputation: 42582
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
Reputation: 6082
Two answers
script/destroy controller cars #rails 2
script/generate controller -T --[skip|no]-views --[skip|no]-helper
Where you can use either skip
or no
as a prefix
Upvotes: 0
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
Reputation: 15525
Another solution could be:
svn revert .
in the Rails application root directory.Upvotes: 2
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