:expire_after rails 2.3.11 workaround
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
# workaround for https://rails.lighthouseapp.com/projects/8994-ruby-on-rails/tickets/6634-railsrack-inconsistency-about-expires_afterexpires-cookie-option#ticket-6634-3 | |
# expiration issue | |
# drop into RAILS_ROOT/config/initializers/expires_fix_2311.rb | |
# | |
require 'rack' | |
Rack::Utils.class_eval do | |
class << self | |
def set_cookie_with_expire!(header, key, value) | |
if value[:expires].blank? && value[:expire_after] | |
value[:expires] = Time.now + value[:expire_after] | |
end | |
set_cookie_without_expire!(header, key, value) | |
end | |
alias :set_cookie_without_expire! :set_cookie_header! | |
alias :set_cookie_header! :set_cookie_with_expire! | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Super useful -- thank you!