Rails redirect_to https,同时保留所有参数 [英] Rails redirect_to https while keeping all parameters

查看:80
本文介绍了Rails redirect_to https,同时保留所有参数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在这样重定向到https:

I'm redirecting to https like so:

redirect_to :protocol => 'https://', :status => :moved_permanently

但是,参数不会像这样通过.我可以这样传递特定的参数:

However, the parameters don't go through like this. I can pass specific parameters through like this:

redirect_to :protocol => 'https://', :status => :moved_permanently, :param1 => params[:param1], :param2 => params[:param2]

我如何做到这一点,使其仅通过url上的每个参数,而不必显式声明每个参数?

How would I make it so that it just passes through every parameter on the url instead of having to explicitly declare each parameter?

推荐答案

弄清楚了:

redirect_to({:protocol => 'https://'}.merge(params), :flash => flash)

这将通过重定向保留所有URL参数.

This will keep all URL params through the redirect.

这篇关于Rails redirect_to https,同时保留所有参数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆