简体   繁体   中英

Append query string to all rails routes

I've run into a safari 6 issue where it blocks third party iframe cookies unless the user has visited the domain outside of the iframe. The only fix seems to be this one here: Safari 3rd party cookie iframe trick no longer working?

But this involves some ugly workarounds (popping open a new browser window and closing again). The preferred solution I would like to take is to encrypt the session id and and append it to all routes as a query parameter. I could then use a before filter to retrieve the session by decrypting the id and loading it from the session store.

So what I can't figure out is if there's a way of appending a query param to all routes without having to edit each link directly? ie by adding something to my routes file.

Override the default url options.

You can do so for your entire application in the application_controller :

def default_url_options(options = {})
  options.merge({ :session_id => request.session_options[:id] })
end

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM