我试图返回redirect_to并传递额外的参数。这里是我在我的控制器中有:使用redirect_to并传递额外参数
redirect_to(env['omniauth.origin'], :hello => "hello world")
这是重定向到URL正确,但你没有被传递。想法?
我试图返回redirect_to并传递额外的参数。这里是我在我的控制器中有:使用redirect_to并传递额外参数
redirect_to(env['omniauth.origin'], :hello => "hello world")
这是重定向到URL正确,但你没有被传递。想法?
是env['omniauth.origin']
a String?如果是这样,我认为这不可行。您可以尝试添加参数为:
redirect_to(env['omniauth.origin'] + "?hello=helloworld")
或其他相关内容。
添加路径它在你的路线,并通过HelloWorld作为参数
redirect_to(route_in_file_path('helloworld'))
添加功能ApplicationController
类
class ApplicationController < ActionController::Base
def update_uri(url, opt={})
URI(url).tap do |u|
u.query = [u.query, opt.map{ |k, v| "#{k}=#{URI.encode(v)}" }].
compact.join("&")
end
end
helper_method :update_uri # expose the controller method as helper
end
现在,你可以做到以下几点:
redirect_to update_uri(env['omniauth.origin'], :hello => "Hello World")
是您的目标(omiauth)外部网址? – Deradon 2012-04-05 23:50:32
不,它不是一个外部URL – AnApprentice 2012-04-05 23:55:11