Skip to main content
Ask A Question
You’re not receiving notifications from this thread.

Handling multiple Account types

Rails • Asked by Orlando Del Aguila

Hello Guys,

I'm doing some research on how to handle multiple account types. In our app, we will have two types of accounts. Parents and Schools. These accounts will never change types, for example a Parent becoming a School.

Schools will have different relationships than Parents, but both will have the ability to login into their accounts (different UIs for both models).

I'm thinking in going with one Account per model, and have an account type to differenciate between Parents and Schools

class Account < ActiveRecord::Base
  # account_type in ["parent", "school"]

class School < ActiveRecord::Base
  has_many :accounts, as: :user

class Parent < ActiveRecord::Base
  has_one :account, as: :user

Then the idea is to use Pundit to handle authorization

What do you think?, does this sounds like a good approach?


Hey Orlando,

Would the Account be what the user logs into in your example?

I think that would make sense. You can then have multiple users for a single school (say several administrators) or even both parents could have separate accounts with your app.

Everyone could login through the same Account sign in form and then be redirected appropriately to the various views for parents or schools depending on their account type. That's probably the easiest experience for your users than having two separate login pages, one for parents only and another for schools only.


Yes, that's exactly what I want, Account will have the login information (username, password etc), and the records will reference either Parent or School.

I'll go ahead with this implementation and see how it goes.


Awesome, good luck and let us know how it goes! Only other thing I'd mention is you might want to change the name of Account to User so it's more standard for anyone working on the code later on. 🤘

I also have the same requirements the best solution i have found is using "devise + rolify+ cancancan" and then customise devise controller to add roles and after_sign_in_path on the basis of roles.

Login or Create An Account to join the conversation.

Subscribe to the newsletter

Join 30,005+ developers who get early access to new screencasts, articles, guides, updates, and more.

    By clicking this button, you agree to the GoRails Terms of Service and Privacy Policy.

    More of a social being? We're also on Twitter and YouTube.