Domain modeling question, organizations and users

Hi everyone,

First a quick intro, I’m Roneesh, new-ish to rails, I started last fall by taking the web dev course at The Starter League in Chicago, IL. I’ve been coding away ever since.

I’m working on an app with a friend right now that manages guest registration for work spaces. The idea is that the work space puts a computer on their secretaries desk that guests use to register, they then get handy e-mails like wifi info and the person they’re there to visit gets notified via sms and email.

We built the app, but want to re-do some core domain modeling.

So, currently, most users never log into the app (they’re visiting guests), they just go through a four-screen process that logs their reason for visit. However, we anticipate that each work space will have 1-3 users (secretary, office manager, etc) who want to log into the app and see things like guest analytics, change the text sent out in e-mails, print guest usage reports, etc.

What’s the best way to model this?

Right now when someone goes to the app, they sign up with their e-mail, and they in effect represent their organization. This doesn’t seem flexible to us, and it doesn’t allow multiple users to see the same data (like a visitor log) unless they share login information.

Should we have an organization model, and organization has_many users? Then when a new user signs up, they also create an organization as well? And then they can add users to their organization via an admin panel?

Another way I can think of it is that rather than organization table, all the data has a Postgres style column that is an array of admin user_id’s, that way all the guest visiting data can be seen by any user_id in that array. That seems really hacky and prone to trouble though. (But also kinda fun!)

I want to keep this short, so I’ll not explicate anymore, however let me know if something is not clear and I’ll explain further. if anyone wants to talk about this in person, feel free to call at 469-337-9220 or email at

Any and all help/feedback appreciated! Thanks everyone!



You might consider a nosql db for this. If you have the chance to rewrite this. Consider this idea. You have an collection of organizations with email addresses. As each person signs up, you match the email addresses, and save into another collection everything about that person, including the organization they belong to. The admins for that organization can login and pull reporting data off the list of everyone who has logged in and do with it as they please. You set up in the admin a filter on admins so that they only see what is pertinent to their people. The beauty is that your screens and what you need drives this, not trying to fit this to a tables/rows thing. The hardest thing to get with no sql db’s is that you have to relearn how you think about data, once you free your mind on this, you will wonder why so many insist on using them still even now. I find for most applications they are quite appropriate, even more so than sqlizing everything. I hope that helps in some way.


Roneesh, here are my thoughts, first I would implement a role object. A person (user) can play the role of either an administrator or a guest:

person (1) --- (0..1) administrator || guest

A person belongs to an organization:

organization (1) --- (0..1) person

Further more, you may designate an organization as the ‘home’ organization role. Then you can only assign an administrator role to a person who belongs to the home organization.

organization (1) --- (1) home

Then a session would be a transaction between the guest and the workspace tied to the home organization.

organization [home] (1) --- (1..*) workspace (1) --- (0..*) sessions (0..*) --- (1) guest


Hey @roneesh,

I think your first inclination is correct: an organization model, and organization has_many users. When a new user signs up, that creates an organization, and then they can add users to their organization via an admin panel.

You would also then have a Guest or Visitor model which belongs to an organization.

I would look at Clearance for your user authentication. It is very straightforward and provide the basic login functionality you need, but devise would also work.

I would not use a NoSQL database for this, you’re better of sticking with a relational database and Rails defaults as you have a fairly standard application.

I hope that helps, please let me know if you have any follow up questions.