You’re not receiving notifications from this thread.
Domain & Subdomain Routing Constraints in Rails Discussion
THANK YOU! I've been at this all day working with acts_as_tenant. Had some issue with some "undefined method `arity' " error when I added the acts_as_tenant(:account) to a model. Nothing much on the internet - but turned out it was such a simple updating of the gem to resolve it. (just in case anyone else comes across this issue like me). It's 2am here now. Tired. EEEK!
Anyway, thank you so much for explaining the final piece of the puzzle for multi-tenancy domain constraints in detail.. Appreciate it. Cannot wait to try out this with a custom domain on a live site. Going to try host the app using Hatchbox. I normally use Heroku but going to make the switch now.
Savage work dude!!
This episode is right on time, just what I needed. Quick little detail, around 1:50, I had to do more than set config.hosts =nil. I also had to comment out config.hosts in environments/development.rb before the app would start.
FYI @chris, you actually can use localhost (well at least on Firefox and Chrome).
localhost will act as the top-level domain, so if in dev you use an URL like:
my-subdomain.my-app.localhost:3000, rack will consider the
request.subdomain to be
my-subdomain. So no need for
lvh.me anymore ;)
I recently created a DomainConstraint in an app and used a database query which checks to see if there is a match with any of the saved domains. I do see now that it does add the query to every request but the cost is just a couple of milliseconds. I suppose that I could figure out a way to avoid the database query by caching the saved domain values or instead setting a general constant for the main (i.e. non-custom) domains and doing a non-match against that. I wonder though if it is worth the effort at this point not to mention the added complexity. Are there other hidden costs beyond the few milliseconds I should be considering?