know the domain of the action called in rails
I have 2 domain: domain1.com and domain2.com
how can i know what is the domain that the user used to call a action?
like
domain1.com/开发者_C百科controller/action
i want get domain1.com from the action
is possible?
thanks
this should be possible by looking at the request object, see chapter 9.1 in the Guide.
domain(n=2) The hostname’s first n segments, starting from the right (the TLD).
Hope this helps.
Use the host
method. If you require the port as well, use host_with_port
.
精彩评论