Created
April 19, 2010 17:25
-
-
Save toyflish/371318 to your computer and use it in GitHub Desktop.
rails 2.3.5, Activerecord-sessionstore takes session-id from get-vars if passed by shockwave flash (uploadify) using rack-middleware
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# part of config/enviroment.rb | |
... | |
Rails::Initializer.run do |config| | |
# Load model files from sub folders | |
config.load_paths += Dir["#{RAILS_ROOT}/app/models/*"].find_all { |f| File.stat(f).directory? } | |
# Load middleware - initially used by flash-session-hack | |
config.load_paths << "#{RAILS_ROOT}/app/middleware" | |
.... |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# this file should sit at config/initializers/flash_session_middleware.rb | |
ActionController::Dispatcher.middleware.insert_before( | |
ActiveRecord::SessionStore, | |
FlashSessionCookieMiddleware, | |
ActionController::Base.session_options[:session_key] | |
) |
How can I use that middleware for Rails 3?
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
identify session from Get-vars in Rails 2.3.5 using middleware and Activerecord-Sessionstore
after looking at some good writeups( thewebfellas and RailsTips ) that doesn't fit my conditions (Rails 2.3.5, Activerecord-Sessionstore) I got deeper into rack and made some small fixes.
4 ease steps to get it run
<%= request.session_options[:key] %>=<%= u cookies[request.session_options[:key]] %>
don't forget to pass the authenticity_token as well:
authenticity_token=<%= form_authenticity_token if protect_against_forgery? %>
if it doesn't work some hints to check
rake middleware
should show something like this
make sure FlashSessionCookieMiddleware is in the right position ( it has to be before ActiveRecord::SessionStore). If you don't use ActiveRecord::SessionStore your stack will look different. Therefore you should gues wich is your SessionStore and apply this to your flash_session_middleware.rb file, where you define where to insert your FlashSessionCookieMiddleware