Currently using rails 3.2.8 version. I found this bug when i tried to delete a controller sass.
Mistakenly i typed
rails d controller ssss instead of rails d controller sass
Console is showing the messsge as ssss.js.coffee , ssss_controller.rb removed
As i dont have controller ssss, then why it has to accept the wrong name.
This is not a bug.
... that said, maybe someone else might think it is.
It feels odd that you get this misleading output:
my-project :: (master*) » rails d controller idonotexist
I think when you got a hard-to-see typo like the one above this can lead to a few minutes of frustration. @steveklabnik why do you think we should not fix this? Is it hard to decide wether the controller actually exists or are there other reasons not to touch this?
Well, for one, I'm not sure of what all the implications are. What if the controller doesn't exist, but the helpers do? The tests? The views?
I see rake tasks as macros. After running this task, the idonotexist controller is deleted. Doesn't matter to me if it existed or not.
I think there's just too many edge cases to properly make this 'work.'
Thanx @senny for your explanation this issue more deeply
The same happens with rails d model idonotexist:
rails d model idonotexist
$ rails d model idonotexist
I agree with Steve. I think this is not a bug.
@frodsan This is should be treated as a bug.We need to find out the possible way to fix it.
I think either opinion is fine. I see how @steveklabnik argues that it is just a handful of scripts that you can run but you need to know what is happening. I think we should get one more opinion from a rails committer and then close it or attach a PR.
@rafaelfranca what do you think?
I side on not considering this a bug.
Okay, so we don't consider this a bug. This doesn't mean that it can't go into Rails, but if it's a feature request, we don't keep the issue open. Please submit a PR to change this behavior, or ask for feedback on rails-core. Thanks.
@judearasu just to clarify: if this is a bug is a bug in Thor, no in Rails. Rails is just using actions provided by Thor for generators.
This can be seen like a % rm -fr unexistingfile, if the file doesn't exists it won't raise an error
% rm -fr unexistingfile
@judearasu the method to remove files in thor: https://github.com/wycats/thor/blob/master/lib/thor/actions/file_manipulation.rb#L287-293
I agree that this is not a Rails bug as @guilleiguaran pointed.