Arnold_Sanders
Arnold_Sanders

Reputation: 150

Inspect request object for path or url

I am trying to implement subdomains in my App. I have a wide sweeping restriction that says that every request has to have a subdomain. However what I really want to say is, every request that is not to the root path will need a subdomain.

The problem is that I am doing this action in my controller and I don't know how to access the request object to check and see if it is going to the root action. Is there a way to say:

if request.some_method != root_path
Account.find_by_subdomain request.subdomain
end 

Any leads would be greatly appreciated

Upvotes: 1

Views: 755

Answers (1)

fylooi
fylooi

Reputation: 3870

According to http://guides.rubyonrails.org/action_controller_overview.html#the-request-object, you should be able to call request.domain(3) to get the subdomain.

Upvotes: 1

Related Questions