influitive / apartment

Database multi-tenancy for Rack (and Rails) applications
2.67k stars 460 forks source link

Accessing the tenant in a different URL format. #606

Closed aniket-02 closed 5 years ago

aniket-02 commented 5 years ago

Hi Team, This is a small query not an issue. Could you please tell me how could we do the following.

Instead of doing something like tenant.lvh.me:3000

I want to do something like

lvh.me:3000/tenant OR lvh.me:3000#tenant

I have seen Elevators using Hash, Subdomain etc. Can we leverage those to achieve this result?

lcjury commented 5 years ago

Check the custom elevator section

Elevators give you the current [rake request] (https://www.rubydoc.info/gems/rack/Rack/Request/Helpers), so you can use methods like path to get the current path and return what tenant you want to connect to.

btw, I wouldn't recommend using the #tenant id selector, as it has another use in the browser and you're gonna completely screw it use for your users.

mikecmpbll commented 5 years ago

(just in addition to the correct advice from @lcjury , you couldn't use anchors anyway as they're not submitted to the server!)