-
Notifications
You must be signed in to change notification settings - Fork 21.6k
-
Notifications
You must be signed in to change notification settings - Fork 21.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Rails destroy command concatenates first/last lines of config/routes.rb #15913
Comments
I reproduced the same error on Rails 4.1.1 and Rails 4.1.2 when following your gist. For Mac OS, you need to change the sed commands to prevent the error 'sed: -i may not be used with stdin' . The gist to reproduce the bug on a Mac machine is here. Possibly, we can just ensure a line break before the end after each destroy command in the routes.rb |
I found that a problem is not in rails itself, but in thor gem. This is corresponding code line in rails: https://github.com/rails/rails/blob/master/railties/lib/rails/generators/actions.rb#L97 |
This issue also applies to Rails 4.2.0. |
When there is a single scaffold in the routes.rb with no other lines then revoking/destroying it will create a routes.rb file with a syntax error. This is because the sentinel for the Thor `route` action didn't include the newline but the logged route code did. The fix is to add the newline to the sentinel and remove it from the the logged route code. Fixes #15913. Conflicts: railties/CHANGELOG.md
When there is a single scaffold in the routes.rb with no other lines then revoking/destroying it will create a routes.rb file with a syntax error. This is because the sentinel for the Thor `route` action didn't include the newline but the logged route code did. The fix is to add the newline to the sentinel and remove it from the the logged route code. Fixes #15913. (cherry picked from commit 1c59ffc) Conflicts: railties/CHANGELOG.md
In Rails 4.1.1, when only one resource (foo) has been created and all lines that are empty or contain only comments have been removed from routes.rb, running
rails destroy scaffold foo
will concatenate the first and last lines of routes.rb and result in a NameError.Rails.application.routes.draw doend
This gist can be used to reproduce the bug.
The text was updated successfully, but these errors were encountered: