This project is archived and is in readonly mode.
'rails destroy scaffold' broke routes.rb
Reported by Sasha Koss | July 31st, 2010 @ 04:39 PM | in 3.0.2
After
rails generate scaffold posts title:string body:text
...
rails destroy scaffold posts
in routes.rb (double |map|):
Simko::Application.routes.draw do |map| |map|
...
end
Comments and changes to this ticket
-
Sasha Koss July 31st, 2010 @ 04:39 PM
ruby 1.9.2dev (2010-07-11 revision 28618) [x86_64-darwin10.4.0]
Rails 3.0.0.rc -
Rohit Arondekar August 1st, 2010 @ 03:38 AM
- 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 ... end
Can you create a new app using RC and confirm that it's not passing the map arg?
-
Sasha Koss August 1st, 2010 @ 05:11 AM
Maybe I generated application with beta 4, and after that use RC generator.
-
Rohit Arondekar August 1st, 2010 @ 08:31 AM
- 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 August 1st, 2010 @ 09:28 AM
- Assigned user set to Rohit Arondekar
I will attach a patch for this soon.
-
Rohit Arondekar August 1st, 2010 @ 11:27 AM
- Assigned user changed from Rohit Arondekar to José Valim
The following patch fixes this.
Credits: Jose :)
-
Santiago Pastorino August 2nd, 2010 @ 02:07 AM
- Milestone cleared.
Rohit, please ping me on IRC when you be online. I have a better solution but also we need tests.
-
Rohit Arondekar August 2nd, 2010 @ 07:46 AM
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 August 2nd, 2010 @ 07:59 AM
Add it to the generators test. Create a scaffold, manually change the routes file and then revoke it.
-
Repository August 2nd, 2010 @ 02:55 PM
(from [c544fcc8eb891e9066bae5eb1478c6823b1f6203]) Failing test to check for route file corruption if legacy map parameter is used. [#5263 state:open] http://github.com/rails/rails/commit/c544fcc8eb891e9066bae5eb1478c6...
-
Repository August 2nd, 2010 @ 02:55 PM
- 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 state:committed] http://github.com/rails/rails/commit/e6331b1e97d608c46aaadd1814a1e3...
Create your profile
Help contribute to this project by taking a few moments to create your personal profile. Create your profile »
<h2 style="font-size: 14px">Tickets have moved to Github</h2>
The new ticket tracker is available at <a href="https://github.com/rails/rails/issues">https://github.com/rails/rails/issues</a>
People watching this ticket
Attachments
Referenced by
- 5263 'rails destroy scaffold' broke routes.rb (from [c544fcc8eb891e9066bae5eb1478c6823b1f6203]) Failing...
- 5263 'rails destroy scaffold' broke routes.rb [#5263 state:committed] http://github.com/rails/rails/co...