Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
:expire_after rails 2.3.11 workaround
# 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
@agibralter
Copy link

agibralter commented Apr 5, 2011

Super useful -- thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment