I want to remove the subdomain from root path.
I tried adding :subdomain => false
to the root
command in routes.rb
file without success: when I enter manually a subdomain in the URL, the subdomain stays and will not be removed.
Example:
my root is => lvh.me:3000
enter subdomain manually => xyz.lvh.me:3000 and hit enter then it remains the same
This is what I tried already in my routes.rb
file, without success:
root :to => 'home#show', :subdomain => false or
root :to => 'home#show', :constraints => { :subdomain => false }, via: [:get]
write this in application controller. this will work.
before_action :check_subdomain
def check_subdomain
unless company_signed_in?
if request.subdomain.present? && params[:controller] == "companies/registrations" && params[:action] == "new"
redirect_to root_url, subdomain: false
end
end
end
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments