简体   繁体   English

Rails 3,如何在路由中获取应用程序URL

[英]Rails 3, How to get Application URL inside routes

I thkink this is a easy question, but I didn't find the solution. 我认为这是一个简单的问题,但我找不到解决方案。 In Rails, How can I get my application URL inside routes? 在Rails中,如何在路由中获取应用程序URL?

Something like: 就像是:

get '/foo', to: redirect("http://whatheverurl.com/?bar=#{MY_APPLICATION_URL}")
  match '/foo', :to => redirect { |params, request|
    "http://whatheverurl.com/?bar=#{request.env['HTTP_HOST']}"
  }

You could do something like this: 你可以这样做:

  match "/web_site", :to => proc { |env|
    [301, { 
      'Location' => "http://www.greenviewdata.com?from=#{env['HTTP_HOST']}" 
    }, ["Go here instead: http://www.greenviewdata.com?from=#{env['HTTP_HOST']}"]]
  }

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

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