Multi-tenancy (SaaS)

I’m using Ruby on Rails as my API and I would like to know how I’d go about doing multi-tenancy for my app as a SaaS. On the rails side I see there is a gem called ‘acts_as_tenant’ which seems to work really well.

What’s puzzling me the most is the sub-domain so on the rails side it knows what ‘account’ is being used and returns the appropriate data to the front end. I haven’t found anything in the documentation that handles the sub-domain in the routes and allowing it to be passed to the Rails backend. Please ask me any questions if I’m not making myself clear so I can get some advice for how I can do this.


The same Ember App is going to consume API from different endpoints, or each Ember app has its own API endpoint, and you’re rendering a different app depending on the user account/role?

I will have one Ember App and one Rails App. What I’d like to do is the Ember App to detect the sub-domain and pass that to the Rails App to respond back with the accounts data.

Is that clear?

That’s definitely doable. If you’re using ember-data try setting the host property on the adapter: Customizing Adapters - Ember Data - Ember Guides . If you are not using ember-data you will need to set the host for each of your $.ajax requests.

1 Like

@xrl that looks interesting and I’ll look into this, thank you. Do you know how I can test this while in development mode, in Rails we use ‘Pow’ is there anything similar which can be used with emberjs?

I use Pow with Ember. Just use Pow’s port proxying.

If, for example, you are using ember-cli on port 4200, then echo 4200 > ~/.pow/my-project and it will be available at as long as you are running the ember server. I tend to use this technique for rails projects as well :smile:

Thanks @amiel. I’ll look into this.