Search code examples
ruby-on-railssubdomain-fu

How to get subdomain fu working in development on my local machine


I cloned a github repo using subdomain fu but I can't seem to get the site to load properly. I always get the same error:

I tried signin.localhost.local:3000, which seems to be working to get the signin/signup pages working. However, when I go to login (from signin.localhost.local:3000) it keeps "signin" at the front like so:

sub1.signin.localhost.local:3000

in prod it works perfectly but for some reason it keeps signin here when it is not suppose to. Also, if I try just removing "signin" and going to sub1.localhost.local:3000, it tells me again "can't find account with subdomain = ". very frustrating.

Here is my hosts file right now:

127.0.0.1       localhost signin.localhost.local sub1.localhost.local signup.localhost.local

Solution

  • Working with subdomains in development mode can be really tricky. If you're on a Mac and the project is using a reasonably recent version of Rails, I'd recommend using Pow which will let you use subdomains without any fancy trickery.

    Once you've installed it, you can add a symlink to a project to your ~/.pow directory and then access the app at app_name.dev and use subdomains, such as signin.app_name.dev as well.