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.

Small generator issue for generator in config/initializers/session_store.rb (Rails 3.0.0.rc2)

#5434

When running rake rails:update using Rails 3.0.0.rc2, it will not generate the correct session key. It generates:

MyApp::Application.config.session_store :cookie_store, :key => '_config_session'

Instead of:

MyApp::Application.config.session_store :cookie_store, :key => '_my_app_session'

Reported by Willem van Bergen · August 24th, 2010 @ 10:14 AM

State: resolved
Milestone: none
Assigned to: José Valim José Valim
Importance: Low

Activity

  1. Rohit Arondekar
    Rohit Arondekar
    • Assigned user set to José Valim
    • Importance changed from to Low

    This looks very similar to #5207 rake rails:update replaces application name

    Assigning to Jose, since he knew how to fix that issue.

    August 24th, 2010 @ 03:20 PM

  2. Neeraj Singh
    Neeraj Singh
    • State changed from new to open
    • Tag changed from rails:update generator session_store.rb to rails 3, rails:update generator session_store.rb, patch

    Attached is code patch.

    August 24th, 2010 @ 04:02 PM

  3. José Valim
    José Valim

    Nice Neeraj! Can you try to add a test case? You can reproduce the rake test calls inside app_generator_test.rb!

    August 24th, 2010 @ 04:13 PM

  4. Marjan Krekoten'
    Marjan Krekoten'

    I attached patch that fixes this issue. And also added test for it.

    August 24th, 2010 @ 04:56 PM

  5. Marjan Krekoten'
    Marjan Krekoten'

    Oops... I missed that there is a patch already :)

    August 24th, 2010 @ 04:57 PM

  6. José Valim
    José Valim

    Krekoten, thanks for the patch! Your fix looks good however the test needs to be improved. It relies to heavily on stubs, meaning that minor changes in Thor or Rails can make it fail, even when it should not. Could you please try to provide a test that does not use stubs/mocks?

    August 24th, 2010 @ 05:00 PM

  7. Marjan Krekoten'
  8. Marjan Krekoten'
    Marjan Krekoten'

    Well, I didn't find better way. We need that stubs to execute generator with already initialized app or it will not fail.

    August 24th, 2010 @ 06:32 PM

  9. Fred Wu
    Fred Wu

    Hey guys,

    Since I was the one who submitted the app_name fix, here's my patch for it. I've improved the tests a bit also.

    August 25th, 2010 @ 02:38 AM

  10. Repository
    Repository
    • State changed from open to resolved

    (from [83f4507cf153ea6081dd70326f5f3a0331cc167e]) Fixed the session name generated by the app_generator. Also refactored the corresponding test suites to be cleaner. [#5434 Small generator issue for generator in config/initializers/session_store.rb ... state:resolved]

    Signed-off-by: José Valim jose.valim@gmail.com
    http://github.com/rails/rails/commit/83f4507cf153ea6081dd70326f5f3a...

    August 28th, 2010 @ 10:08 PM

  11. Repository
    Repository

    (from [3edd3d052efc6d39345aaa3258109ec2fc92baa4]) Fixed the session name generated by the app_generator. Also refactored the corresponding test suites to be cleaner. [#5434 Small generator issue for generator in config/initializers/session_store.rb ... state:resolved]

    Signed-off-by: José Valim jose.valim@gmail.com
    http://github.com/rails/rails/commit/3edd3d052efc6d39345aaa3258109e...

    August 28th, 2010 @ 10:09 PM

  12. Willem van Bergen
    Willem van Bergen

    The new generator uses the directory name to create the session key prefix, instead of the application name. So, when I fork "MyApp" in a directory called "their_app", this is what I'll get.

    MyApp::Application.config.session_store :cookie_store, :key => '_their_app_session'
    

    I think it should generate:

    MyApp::Application.config.session_store :cookie_store, :key => '_my_app_session'
    

    Sorry for nitpicking guys! :)

    August 30th, 2010 @ 06:24 AM

  13. Fred Wu
    Fred Wu

    Good catch Willem.

    Here's the patch for it.

    August 30th, 2010 @ 12:54 PM

  14. Marjan Krekoten'
    Marjan Krekoten'

    :) last patch almost identical to mine just said in other words...

    August 30th, 2010 @ 01:06 PM

  15. Fred Wu
    Fred Wu

    Ah it appears so. :D

    @José: Any change to include either the patch in 3.0.1?

    September 24th, 2010 @ 07:48 AM

  16. José Valim
    José Valim
    • State changed from resolved to open

    September 24th, 2010 @ 08:06 AM

  17. Repository
  18. Repository