I am having a problem with how will I correctly set the models of my rails application. I will use the gem Apartment for multi-tenancy and the gem Devise for authentication.
What I want to achieve is that I will have 3 user levels. The admin, owner, and user.
Basically, the admin handle all owners in the site, he can add, edit, and delete owners. Imagine that admin owns the whole website (https://example.com).
The owner will handle users, he can add, edit, and delete users. If the admin owns (https://example.com) then the owner only owns (https://owner1.example.com).
Each subdomain will have its own users handled by the owner. And all owners are handled by the admin.
What I have come up currently is having 2 models.
- WebsiteAccount
- UserAccount
WebsiteAccount will have subdomain and owner_name columns. UserAccount will have email, password, and user_level. Where user_level can be owner or user.
Then the Devise will be used on UserAccount model. The UserAccount model will only show data based on the subdomain.
Now the question is where does the admin account fall?
Do I create a separate model for it and also use Devise gem on that?