0

I'm quite noob in this:

Question part 1: As I understand then FirstSubdomain class can be used to enable second level subdomains, but where and how should I declare it to enable it?

Question part 2: If you make a new schema with Apartment like this:

Apartment::Tenant.create 'newtenant'

then it gives you also a subdomain like newtenant.myapp.com. Is there a way to create 2nd level subdomains straight from the console or do I get something very wrong?

Andres
  • 2,099
  • 3
  • 22
  • 39

2 Answers2

2

I think you are missing something important: you have to define subdomains through the DNS settings for your domain.

Another tip: use the lvh.me domain for local testing with subdomains. If you browse to lvh.me:3000 you will actually browse to localhost:3000. If you browse to sub.newtenant.lvh.me:3000 the same happens.

zwippie
  • 15,050
  • 3
  • 39
  • 54
  • Possible, but at the moment all I need to do for a new first-level subdomain to work is create it from the console with `Apartment::Tenant.create 'yetanothertenant'` and add sth like `yetanothertenant.myapp.com` to my hosts-file on the proper line. Is there something similar I need to do with second level subdomains? – Andres Apr 13 '15 at 12:43
  • If you want to use your hosts file, you can just add ie. `sub.yetanothertenant.myapp.com`. – zwippie Apr 13 '15 at 13:17
0

Enabling FirstSubdomain is an Apartment initializer job (Apartment::Elevators::FirstSubdomain) and question part 2 is basically answered in question- it works in my localhost just like that: `Apartment::Tenant.create 'newtenant'.

Question came up because a bit messy situation in developing with little custom-made system for reading tenant-name from url. That's why I thought my multi-level subdomains don't work.

I'll leave the question up just in case someone finds it (or answers) useful.

Andres
  • 2,099
  • 3
  • 22
  • 39