This project is archived and is in readonly mode.

#5642 ✓stale

Clean up & Optimize session_store config

Reported by bgentry | September 16th, 2010 @ 09:33 PM

See this code block

The Rails::Application::Configuration#session_store method has several issues. First of all, when trying to set this up with DataMapper, I assumed that session_store(:data_mapper_store) would be the way to enable DataMapper session storage. This does not work, however, because DataMapper follows ActiveRecord's session class structure (Rails::DataMapper::SessionStore, just like Rails::ActiveRecord::SessionStore).

Rather than following an agnostic approach that all ORMs can adopt, ActiveRecord session support is hardcoded into this method.

In order to make this work with session_store(:data_mapper_store), the DataMapper team would have to rename or alias the existing class to ActionDispatch::Session::DataMapperStore. However, even if they make that change, this method is caching the symbol as @session_store and performing the string conversion/constant lookup every time it is called. Even if the structure of this method is not changed, we should be caching the Class itself once we've looked it up.

One other issue at this point is that I can configure my session store with MyApp::Application.config.session_store = Rails::DataMapper::SessionStore, but even if I do that I still have to manually require 'dm-rails/session_store' before declaring my session_store. It would be great if a solution could also handle autoloading of the required class.

I'd like some advice on how this should be resolved. It seems reasonable that AR should not be hardcoded into this method, but should instead follow the same agnostic approach that every other ORM should follow. Exactly what that approach should be is open for debate.

Comments and changes to this ticket

  • Santiago Pastorino

    Santiago Pastorino February 2nd, 2011 @ 04:31 PM

    • State changed from “new” to “open”

    This issue has been automatically marked as stale because it has not been commented on for at least three months.

    The resources of the Rails core team are limited, and so we are asking for your help. If you can still reproduce this error on the 3-0-stable branch or on master, please reply with all of the information you have about it and add "[state:open]" to your comment. This will reopen the ticket for review. Likewise, if you feel that this is a very important feature for Rails to include, please reply with your explanation so we can consider it.

    Thank you for all your contributions, and we hope you will understand this step to focus our efforts where they are most helpful.

  • Santiago Pastorino

    Santiago Pastorino February 2nd, 2011 @ 04:31 PM

    • State changed from “open” to “stale”

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=""></a>

People watching this ticket