ruby-on-rails - 带有 GET/POST 参数的 Rails redirect_to "www.somewebsite.com"?

标签 ruby-on-rails ruby http-status-code-301 http-status-code-302

我正试图在我的一个 Controller 中发出一个 redirect_to 到一个完全限定的 URL + 我想传递一些参数

我在站点 A 的 Controller 中:

redirect_to: "www.siteB.com/my_controller/my_action?my_parameter=123"

在 Rails 中有没有更好的方法来做到这一点?

最佳答案

如果 SiteB 运行相同的应用程序(即该服务器的路由相同),那么您可以构建您描述的重定向:

redirect_to :host => "www.siteB.com", 
            :controller => "my_controller", 
            :action => "my_action",  
            :my_parameter => 123

请注意,url_for 未处理的任何键都会自动编码为参数。

关于ruby-on-rails - 带有 GET/POST 参数的 Rails redirect_to "www.somewebsite.com"?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2017367/

相关文章:

ruby-on-rails - Devise_token_auth 和 Devise 使用用户名和电子邮件登录

ruby-on-rails - 在 jail 长 json 参数不起作用

ruby-on-rails - 未定义方法 'zero' ... ActiveSupport::OrderedHash

iis - 重定向任何尚未在 IIS7 上使用 301 重定向的内容

.htaccess; 301 重定向不起作用

ssl - https 重定向仅有时有效

ruby-on-rails -/etc/environment 中的环境变量不能被 rails 访问

ruby-on-rails - Rails Slim语法错误

javascript - 测试 Angular/Rails 应用程序的首选方法是什么?

ruby - 在运行时更改 MongoMapper 当前数据库