Forum: Ruby on Rails Controller design for app with different user types

Announcement (2017-05-07): is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see and for other Rails- und Ruby-related community platforms.
2d44487d7d42adeea84c7d231de9a17e?d=identicon&s=25 Joey Ar (nubyonrails)
on 2009-02-02 18:31

I am trying to implement an application where there are different types
of users (about 5-6). The privileges of each type of user varies pretty
drastically and hence when each logs into the application, each will
have his own home page and set of things that he can do that differs
from other types of users.

Since the views would also change (or rather look totally different) for
each of them, I thought it would be better to have totally different
controllers and actions based on the type of users. I have been reading
about how to design this kind of an scenario but have not been able to
stumble upon a sound design as of now. There was one reference to
namespaced controllers... do you think this would be the best approach
for the situation in hand. If you know of any tutorial, that would be

Plus, I see that a lot of my actions don't fall just within the CRUD
actions, I need more... can some lead me to design tips or tutorials for
such a thing too? Any help is appreciated. Thanks in advance!

D93ae163042e0a937941e0ba4d8ed5d7?d=identicon&s=25 Eric (Guest)
on 2009-02-02 20:21
(Received via mailing list)
Roles are fairly well-documented in the blogosphere, even if the roles
are entirely orthogonal. Here are a few readings to get you started:

Are the views actually that different? It may be just that the content
of the profiles is determined by the user's role(s), but the template
can remain the same for all roles.
2d44487d7d42adeea84c7d231de9a17e?d=identicon&s=25 Joey Ar (nubyonrails)
on 2009-02-03 12:59
Hey Eric,

Thanks a lot for the links. The first one was really useful as that
addresses overlapping permissions for various roles and my application,
I suppose, falls in that domain.

As for the views, yes they are radically different for each type of
user. The app brings different types of users together and hence
generally they all don't interact with the same set of models. There are
some common models that they all interact with but many models are
specific to the user type. Hence the views look different for each user
type. That's why I was wondering if I could use something like the

  map.namespace :client do |client|
    client.resources :projects, :preferences
    client.resources :forums do |forums|
      forums.resources :topics

  map.namespace :employee do |employee|
    employee.resources :profile, :calendar
    employee.resources :forums do |forums|
      forums.resources :topics

  ...and so on for each type of user. The above code is just an example,
I've not used the exact project details.

I've used :forums in both user types to just give an example for shared
models but even in those the view would look very different for each
user type.

Can someone tell me if I am on the right path?

This topic is locked and can not be replied to.