Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Make Rails 3.1 use symbols in sessions so it can share Rails 2 sessions.
#...
module MyApp
class Application < Rails::Application
#...
config.after_initialize do
require 'session_patch'
end
end
end
# This patch makes Rails 3 use symbols as storage keys in sessions,
# as Rails 2 did.
module Rack
module Session
module Abstract
class SessionHash
def [](key)
load_for_read!
super(key.to_sym)
end
def has_key?(key)
load_for_read!
super(key.to_sym)
end
def []=(key, value)
load_for_write!
super(key.to_sym, value)
end
def delete(key)
load_for_write!
super(key.to_sym)
end
private
def stringify_keys(other)
hash = {}
other.each do |key, value|
hash[key.to_sym] = value
end
hash
end
end
end
end
end
@schougaard

This comment has been minimized.

Copy link

schougaard commented Feb 1, 2013

Put session_patch.rb in lib/ or similar

@amolpujari

This comment has been minimized.

Copy link

amolpujari commented May 24, 2013

this wont require any more, still keeping it can throw error of cannot modify flash, specially in case of activeadmin

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.