This project is archived and is in readonly mode.
'rails destroy scaffold' broke routes.rb
-
Sasha Koss
ruby 1.9.2dev (2010-07-11 revision 28618) [x86_64-darwin10.4.0]
Rails 3.0.0.rc -
Rohit Arondekar
- Importance changed from to Low
Can't reproduce.
Also when you create a Rails app using RC, the map argument won't be passed to the block.
Rcapp::Application.routes.draw do ... endCan you create a new app using RC and confirm that it's not passing the map arg?
-
Sasha Koss
Maybe I generated application with beta 4, and after that use RC generator.
-
Rohit Arondekar
- State changed from new to open
- Tag set to rails 3.0.0.rc, generators, routes
Confirmed on Rails master.
Indeed it most probably was a beta 4 app. Rails 3 RC does not generate a routes file with the map parameter. The map parameter is deprecated and is only supported to allow legacy routes and is scheduled to be removed in 3.1 iirc.
However since you can still pass the map parameter to the block, doing that and then generating & destroying a scaffold still adds an extra |map| to the routes file. So this is still an issue.
-
Rohit Arondekar
- Assigned user changed from Rohit Arondekar to José Valim
The following patch fixes this.
Credits: Jose :)
-
Santiago Pastorino
- Milestone cleared.
Rohit, please ping me on IRC when you be online. I have a better solution but also we need tests.
-
Rohit Arondekar
I need help with the tests.
I tried writing one in actions_test.rb but I don't think there is a way to revoke an action. Right?
I also tried writing one in the scaffold generator tests, but the route file that is used for the tests does not have the |map| parameter. Also the routes file is copied from — railties/lib/rails/generators/rails/app/templates/config/routes.rb — so either a new legacy file will need to be added, including a copy_legacy_routes method and such. Or maybe inject the |map| into the file before running the generator?
Also can you discuss the better solution here? I may not be very active in IRC for a couple of days (at the time we both can be awake). :)
-
José Valim
Add it to the generators test. Create a scaffold, manually change the routes file and then revoke it.
-
Rohit Arondekar
Here is the failing test.
-
Repository
(from [c544fcc8eb891e9066bae5eb1478c6823b1f6203]) Failing test to check for route file corruption if legacy map parameter is used. [#5263 'rails destroy scaffold' broke routes.rb state:open] http://github.com/rails/rails/commit/c544fcc8eb891e9066bae5eb1478c6...
-
Repository
- State changed from open to committed
(from [e6331b1e97d608c46aaadd1814a1e370bdcdd40a]) Makes rails destroy scaffold don't duplicate routes.draw do |map| |map| when using the deprecated syntax
[#5263 'rails destroy scaffold' broke routes.rb state:committed] http://github.com/rails/rails/commit/e6331b1e97d608c46aaadd1814a1e3...
