rails destroy controller does nothing

问题内容:

I was trying to delete (and then re-generate) the welcome controller in my rails Project. Since I misspelled some things and now nothing is working correctly (I am learning Rails right now)

So I ran

rails destroy controller welcome

But now nothing happens…


I’ve been waiting for over ten minutes for something to happen, but nothing…


No errors or any messages


And my project is as small as it could be …

Any ideas on what I could do? Besides from trashing everything and starting form scratch again?

—Edit—


I fixed my initial problem and my project works again, but being able to delete controllers is something that I would like to be able to.

问题评论:

1  
If you able to learn about how Rails’s generate files for you, you can remove them manually without commands. I know commands are something magic that newcomers love, but understanding what the command does also a good way to learn Rails.
1  
that was/is my problem I don’t know what the magical rails commands do (yet) So I was hoping to use another command, so I don’t forget something and screw up even more 😉
– NIoSaT
1 hour ago

答案:

答案1:

Try to remove routes manually and retry deleting with

rails d controller welcome -p

-p will post output to terminal. Check it for errors. If there are any errors, update answer with information about them. And if no errors are shown, try command again without -p.

Here is a post with lots of comments and answers about this command.

答案评论:

    
how can I delete the routes manually in general? Editing the routes.rb file? When I look into this file I see some routes that I put there, but rails routes gives me even more routes for my other controller/model
– NIoSaT
1 hour ago
1  
Yes, just remove all strings with welcome from routes.rb
    
Ok I will try this later, now I have to fix some other problems right now …
– NIoSaT
41 mins ago
    
I did not delete the routes, but now the rails d controller welcome -p displays something – so I guess it works now again thanks for the help
– NIoSaT
18 mins ago

原文地址:

https://stackoverflow.com/questions/47755447/rails-destroy-controller-does-nothing

Add a Comment