我的路线:
class ActionDispatch::Routing::Mapper
def draw routes_name
instance_eval(File.read(Rails.root.join('config', 'routes', "#{routes_name}.rb")))
end
routes_a.rb
root :to => 'home#index'
controller :home do
post 'terms'
routes_b.rb
root :to => 'business/dashboards#show'
如果我目前位于子域community.website.com
,并且我创建了一个link_to:
= link_to 'Here', terms_path
它返回community.website.com/terms
而不是website.com/terms
。
如何退回website.com/terms
?
答案 0 :(得分:2)
把它放在routes.rb:
中constraints(:host => /community.website.com/) do
match '/terms', :to => redirect {|params, request| "http://website.com/terms"}
end
答案 1 :(得分:0)
通常我不回答我自己的问题,但我认为这会有用:
terms_url(host: request.domain)
host: request.domain
删除子域引用。