url = "www.mysite.com/?param1=abc" redirect_to(url,:param2 => 'xyz') ### Should this go to - www.mysite.com/?param1=abc¶m2=xyz
或者我错过了什么?它似乎不起作用?
解决方法
redirect_to(options = {},response_status = {})
Redirects the browser to the target specified in options. This
parameter can take one of three forms:Hash – The URL will be generated by calling url_for with the options.
Record – The URL will be generated by calling url_for with the
options,which will reference a named URL for that record.String starting with protocol:// (like http://) or a protocol relative
reference (like //) – Is passed straight through as the target for
redirection.
你传递一个String作为第一个参数,所以它使用第三个选项.您的第二个参数被解释为response_status参数的值.
因此,如果您的重定向是内部重定向(到同一个应用程序),则无需指定方案和主机名.只是用
redirect_to root_url(param1 => 'abc',param2 => 'xyz')
如果是外部URL,请在重定向之前构建完整的URL:
url = "www.mysite.com/?param1=abc¶ms2=xyz" redirect_to url
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。