Topic: Multi-client application: user handling


I plan an application for multiple clients. The URLs will be for example like:,, ...

Each client can have multiple users (belonging to one or multiple roles). A user for client 1 should (of course) not be able to login in for client2.
The users are not created by a registration form but by other users of that client.
In addition to that there have to be (a few) users that do not belong to any client. These users should then be able to create users for each client.

So the most important requirements are: log-in, log-out, creation of users, separation of data among the clients, password reset

Can you give me some advise how to do that? Is devise a good starting point? Or should I better create my own solution?
Maybe you even know tutorials that cover this issue!?

Thanks a lot

Re: Multi-client application: user handling

OK, I have be playing around with Devise a little.
In my routes.rb I have:

  scope "/:kreis" do
    devise_for :users
    resources :projects

In order to make Devise work with this scope, I had to add the following to the application controller:

  def default_url_options
    { :kreis => params[:kreis] }

When I visite and click on the login link, I am directed to - as I expected it. But after the successful login I am redirected to instead of
Moreover I am also logged in for all the other clients...
Any ideas how to fix that?

Thanks in advance...

Re: Multi-client application: user handling

I'm not too knowledgeable (yet), but have you considered using sub-domains instead? Instead of having you would have There is some railscasts that explain subdomains: … in-rails-3 (using Rails 3) AND (using the plugin subdomain-fu).

As far as managing separate lists of users for various clients with devise, maybe there should be a client model that has_many users and users belong_to a client.

Unfortunately, I'm not knowledgeable enough yet to give you example code for Devise, but hopefully those ideas help.

Change is a vector. You can have all the change in the world, but if it doesn't go in the right direction, what good is it? |