views:

163

answers:

1

I can't figure out what I'm overlooking, perhaps it's obvious or lack of understanding.

The app I'm working with uses subdomains which on the hosting server work properly. I figured locally installing would kick up some issues around routing, so I read up on making changes to /etc/hosts and using the Ghost gem. Both seem to work fine i.e. localhost:3000/ becomes myapp.local:3000 but I don't understand how to go about logging into a subdomain account. Here's an example...

  • myapp.local:3000/session/new = the default login page for the app
  • myapp.local:3000/signup = default signup page
    • I can create an account here e.g. Sub1
    • The thank you page is shown w/ the reference to sub1.myapp.com which points to the hosted app (the local db shows this domain as well)
  • sub1.myapp.local manually added to /etc/hosts and dscacheutil -flushcache
  • sub1.myapp.local:3000/session/new is the subdomain
    • login attempts return that this isn't a valid domain. This seems to make sense because the local db shows the url as sub1.myapp.com on the hosting server.

So my question is whether there's a local workaround that I can use for development or have I totally missed a fundamental concept along the way?

+2  A: 

hi there,

you might just want to try putting the actual dot com in your /etc/hosts file.

ie:

127.0.0.1 sub1.myapp.com
127.0.0.1 myapp.com
127.0.0.1 anyothersubdomains.myapp.com

what this usually does is trick your computer into thinking it is the host of all of those, so you can't go to the real site anymore in a web browser.

if you do want it to be .local, presumably so that you can refer to the real online site while working on a local copy, you should probably take a look in app/controllers/application_controller.rb (sometimes application.rb) and look for logic in there that helps determine what to do depending on the subdomain. maybe its hard coded to only look for a .com or something.

spotman
Holy cow spotman! that's just the workaround I was looking for... I tried it and it works e.g. I can access the app locally but can't nav to the public domain which for now is tolerable. All I really needed to for now is ensure I can run it locally.Looking through the application.rb there does seem to be a bit of funky redirecting logic. Guess I'll add it to my list of things to learn. Thanks for your help...this had me stumped for the past day or two.
Shawn