Lighthouse has a new layout. Prefer the old one? Return to the old layout, and switch back any time from the link at the top of each page.

This project is archived and is in readonly mode.

'rails destroy scaffold' broke routes.rb

#5263

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

Reported by Sasha Koss · July 31st, 2010 @ 04:39 PM

State: committed
Milestone: 3.0.2
Assigned to: José Valim José Valim
Importance: Low

Activity

  1. Sasha Koss
    Sasha Koss

    ruby 1.9.2dev (2010-07-11 revision 28618) [x86_64-darwin10.4.0]
    Rails 3.0.0.rc

    July 31st, 2010 @ 04:39 PM

  2. Rohit Arondekar
    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
      ...
    end
    

    Can you create a new app using RC and confirm that it's not passing the map arg?

    August 1st, 2010 @ 03:38 AM

  3. Sasha Koss
    Sasha Koss

    Maybe I generated application with beta 4, and after that use RC generator.

    August 1st, 2010 @ 05:11 AM

  4. Rohit Arondekar
    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.

    August 1st, 2010 @ 08:31 AM

  5. Rohit Arondekar
    Rohit Arondekar
    • Assigned user set to Rohit Arondekar

    I will attach a patch for this soon.

    August 1st, 2010 @ 09:28 AM

  6. Rohit Arondekar
    Rohit Arondekar
    • Assigned user changed from Rohit Arondekar to José Valim

    The following patch fixes this.

    Credits: Jose :)

    August 1st, 2010 @ 11:27 AM

  7. Santiago Pastorino
    Santiago Pastorino
    • Milestone cleared.

    Rohit, please ping me on IRC when you be online. I have a better solution but also we need tests.

    August 2nd, 2010 @ 02:07 AM

  8. Rohit Arondekar
    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). :)

    August 2nd, 2010 @ 07:46 AM

  9. José Valim
    José Valim

    Add it to the generators test. Create a scaffold, manually change the routes file and then revoke it.

    August 2nd, 2010 @ 07:59 AM

  10. Rohit Arondekar
  11. Repository
  12. Repository
    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...

    August 2nd, 2010 @ 02:55 PM

  13. Jeremy Kemper