I have a Rails 4 multi-tenant application that uses subdomains with PostgreSQL schemas to βtenantβ the application. I have the wildcard characters "*" set in Heroku and Cloudflare and the site loads, but it continues to "think" that www is a valid subdomain. Because of this, usually valid links (which work in development) do not work in production, because www.mysite.com/accounts/new, etc. Same as asdf.mysite.com/accounts/new. Is there a way to make my application almost ignore www as a subdomain? I would still like mysite.com to redirect to www.mysite.com, but pretty much just set the subdomain to false when it is www?
To make things a little more specific, in my application_controller application I have code that does the following. Pay attention to the comments. In development mode, redirect_to root_url (subdomain: false) works, but during production, it simply redirects endlessly and does not load. To load it, I simply draw the page, but this does not cause the subdomain to be false.
def load_schema Apartment::Tenant.switch!('public') return unless request.subdomain.present? if current_account Apartment::Tenant.switch!(current_account.subdomain) else redirect_to root_url(subdomain: false)
Basically, everything works as expected in development mode, but there are apparently some DNS issues in production that need to be smoothed out, but I can't figure out what to do. Any thoughts?
source share