简体   繁体   English

将查询字符串附加到所有rails路由

[英]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. 我遇到了一个safari 6问题,它会阻止第三方iframe cookie,除非用户访问过iframe之外的域。 The only fix seems to be this one here: Safari 3rd party cookie iframe trick no longer working? 唯一的修复似乎就是这里: Safari第三方cookie iframe技巧不再有效?

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. 我想采取的首选解决方案是加密会话ID,并将其作为查询参数附加到所有路由。 I could then use a before filter to retrieve the session by decrypting the id and loading it from the session store. 然后我可以使用before过滤器通过解密id并从会话存储加载它来检索会话。

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. 覆盖默认的url选项。

You can do so for your entire application in the application_controller : 您可以在application_controller中为整个应用application_controller

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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