How to get the subdomain value from a url?

后端 未结 9 2280
太阳男子
太阳男子 2020-12-09 02:15

how can I get the subdomain value in rails, is there a built-in way to do this?

e.g.

test123.example.com

I want the test123 part of

9条回答
  •  醉话见心
    2020-12-09 02:52

    Use the following method inside your controller

    request.subdomains
    

    This Returns an array of subdomains

提交回复
热议问题