# Refactoring Existing Application For Login Accounts

**URL:** <https://www.ruby-forum.com/t/refactoring-existing-application-for-login-accounts/107252>\
**Category:** Rails\
**Created:** [June 19, 2007, 5:39pm UTC](https://www.ruby-forum.com/t/refactoring-existing-application-for-login-accounts/107252 "2007-06-19T17:39:05Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![rubylover](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/8c91f0/32.png) [@rubylover](https://www.ruby-forum.com/u/rubylover)\
**Post date:** [June 19, 2007, 5:39pm UTC](https://www.ruby-forum.com/t/refactoring-existing-application-for-login-accounts/107252/1 "2007-06-19T17:39:05Z")

</div>

A client has asked me to modify their existing application to allow  
for clients and tutors to be able to login, modify their personal  
information, input time and other actions. The application has a  
single table called contacts and uses single table inheritance to  
define three models Contact, Client (descendent of Contact) and Tutor  
(descendent of Contact). There is also a User model and subsequent  
table that contains the actual user accounts of the employees of the  
client’s company.

The client now wants Tutors and Clients to have their own unique  
logins to allow them to perform various actions depending on what type  
of user they are. For example, a tutor can login and enter their  
weekly hours while a Client can login and see their bill and pay it.

My question is how should I refactor this to allow for clients, tutors  
and users to login, but each be shown a different set of options &  
interface. My initial thought pattern was to move Clients & Tutors to  
the Users table and inherit from it, but I think I need to seek second  
opinion before moving forward.

Any suggestions?

- 

Justin W.  
Second Gear  
[http://www.secondgearllc.com/](http://www.secondgearllc.com/)

---

<div class="post-metadata">

**Author:** ![rubylover](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/8c91f0/32.png) [@rubylover](https://www.ruby-forum.com/u/rubylover)\
**Post date:** [June 21, 2007, 6:05am UTC](https://www.ruby-forum.com/t/refactoring-existing-application-for-login-accounts/107252/2 "2007-06-21T06:05:16Z")

</div>

Anyone?

- j

---

<div class="post-metadata">

**Author:** ![rubylover](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/8c91f0/32.png) [@rubylover](https://www.ruby-forum.com/u/rubylover)\
**Post date:** [June 21, 2007, 3:00pm UTC](https://www.ruby-forum.com/t/refactoring-existing-application-for-login-accounts/107252/3 "2007-06-21T15:00:16Z")

</div>

On Jun 19, 11:38 am, Justin W. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> My question is how should I refactor this to allow for clients, tutors  
> and users to login, but each be shown a different set of options &  
> interface. My initial thought pattern was to move Clients & Tutors to  
> the Users table and inherit from it, but I think I need to seek second  
> opinion before moving forward.

You could store the type of user in the user table using  
polymorphism. That way, you can detect what type of user they are and  
send them to the correct location.
