繁体   English   中英

Rails路由,URL和子域

[英]Rails routes, url and subdomain

我们在应用程序中使用了一些子域。

我们所有的仪表板都有一个子域(pro.domain.com,free.domain.com,vip.domain.com)。 在路由中,每个仪表板都有一个名称namespace :vip do

使用rails url,我希望能够写<%= link_to "Be VIP", vip_pricing_path() %>并重定向到vip.domain.com/pricing

我真的不知道该怎么做。

在routes.rb中:

没有命名空间:

constraints subdomain: 'vip' do
  get '/pricing', to: 'somecontroller#someaction', :as=>:vip_pricing
end

耙路:

vip_pricing GET /pricing(.:format)somecontroller#someaction {:subdomain =>“ vip”}

如果保留名称空间:

namespace :vip do
  constraints subdomain: 'vip' do
    get 'pricing', to: 'somecontroller#someaction'
    ...
  end
end

耙路:

vip_pricing GET /vip/pricing(.:format)vip / somecontroller#someaction {:subdomain =>“ vip”}

暂无
暂无

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

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