Rails: Routing subdomain to a resource

前端 未结 4 1237
野的像风
野的像风 2021-02-06 06:28

Is it possible to map a subdomain to a resource? I have a company model. Currently, using subdomain_fu, my routing file contains:

map.company_root  \'\', :cont         


        
4条回答
  •  我在风中等你
    2021-02-06 07:01

    Using the resource linked from Daniel's answer, in Rails 3 the way to route '/' to a different controller depending on the subdomain is as follows:

    match '/' => 'somecontroller#action', :constraints => { :subdomain => 'yoursubdomain' }
    

提交回复
热议问题