# Single table inheritance for different user types?

**URL:** <https://www.ruby-forum.com/t/single-table-inheritance-for-different-user-types/52177>\
**Category:** Engines\
**Created:** [January 11, 2006, 6:35pm UTC](https://www.ruby-forum.com/t/single-table-inheritance-for-different-user-types/52177 "2006-01-11T18:35:40Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Daniel\_Holmlund](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/74df32/32.png) [@Daniel\_Holmlund](https://www.ruby-forum.com/u/Daniel_Holmlund)\
**Post date:** [January 11, 2006, 6:35pm UTC](https://www.ruby-forum.com/t/single-table-inheritance-for-different-user-types/52177/1 "2006-01-11T18:35:40Z")

</div>

First of all, I wanted to give a harty “thank you” to James A.s for  
creating rails engines, which seems like a very natural way to increase  
codesharing and productivity.

My question is how have people implemented different types of users in  
their Web applications?

As for my application, I use single table inheritance in order to derive  
several different types of users, such as “moderators,” “editors,” etc  
…

For example, let’s say that I want to create a moderator. I define a new  
moderator class and Controller like so:

class Moderator \< User  
end

class ModeratorController \< UserController  
end

My problem with this is that since several functions such as “login,”  
“signup” and others directly call the User class. I cannot simply  
inherit the ModeratorController from UserController without overriding  
everyone of these functions and changing every instance of “User” with  
“Moderator”

I think there must be a simple and elegant solution to this. Any  
suggestions?

---

<div class="post-metadata">

**Author:** ![Daniel\_Holmlund](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/74df32/32.png) [@Daniel\_Holmlund](https://www.ruby-forum.com/u/Daniel_Holmlund)\
**Post date:** [January 11, 2006, 10:09pm UTC](https://www.ruby-forum.com/t/single-table-inheritance-for-different-user-types/52177/2 "2006-01-11T22:09:39Z")

</div>

Hi Daniel -

See my reply on the Rails list to this.

Cheers

- james
