This project is archived and is in readonly mode.

#6131 new
Michael Reinsch

default_url_options set within a controller are not cleared after every request on production

Reported by Michael Reinsch | December 8th, 2010 @ 05:52 AM

With Rails 3.0.3: default_url_options set from within a controller (default_url_options[:something] = "value") won't be cleared after each request in a production environment. Once set, the option will be used until overwritten or explicitly removed. In development mode though, the option is dropped after each request.

For instance, we are using code like this:

  class ApplicationController
    before_filter :set_session_id_parameter
    def set_session_id_parameter
      if device_needs_session_param_in_url?
         session[:_dummy_param_to_force_session_init] = nil  # to make sure we have a session id
         key = Rails.application.config.session_options[:key]
         default_url_options[key] = request.session_options[:id]
      end
    end
  end

In development mode this works fine. But within a production environment (class caching enabled) the session ID parameter once set will stay for all subsequent requests until overwritten again. This was unexpected behavior for us. I also can't find any documentation indicating that this would be the case.

Comments and changes to this ticket

Create your profile

Help contribute to this project by taking a few moments to create your personal profile. Create your profile »

<h2 style="font-size: 14px">Tickets have moved to Github</h2>

The new ticket tracker is available at <a href="https://github.com/rails/rails/issues">https://github.com/rails/rails/issues</a>

Pages