Skip to content

Instantly share code, notes, and snippets.

@avit
Created June 14, 2010 02:41
Show Gist options
  • Save avit/437218 to your computer and use it in GitHub Desktop.
Save avit/437218 to your computer and use it in GitHub Desktop.
# https://rails.lighthouseapp.com/projects/8994/tickets/4743-session-cookie-breaks-if-used-with-custom-cookie-in-rails-238
# http://gist.github.com/431811
if Rails.version == '2.3.8'
class RackRailsCookieHeaderHack
def initialize(app)
@app = app
end
def call(env)
status, headers, body = @app.call(env)
if headers['Set-Cookie'] && headers['Set-Cookie'].respond_to?(:collect!)
headers['Set-Cookie'].collect! { |h| h.strip }
end
[status, headers, body]
end
end
Rails.configuration.after_initialize do
ActionController::Dispatcher.middleware.insert_before(
ActionController::Base.session_store, RackRailsCookieHeaderHack
)
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment