How to get the subdomain value from a url?

后端 未结 9 2283
太阳男子
太阳男子 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 03:14

    current domain with subdomains:

    "#{request.subdomain}.#{request.domain}"
    # or
    "#{request.subdomains.join(".")}.#{request.domain}"
    

提交回复
热议问题