Reputation: 907
Here's the scenario:
An HMO has_many USER (these are the members of the HMO). A User belongs to HMO.
A USER ==Owner of HMO== has_one HMO. HMO belongs_to USER.
Now, when I query Hmo.first.users the OWNER is also included in the list. How can I implement this on RAILS ActiveRecord relationship?
Upvotes: 0
Views: 86
Reputation: 2483
What is the difference between user and owner of HMO?
If you have a boolean flag for the owner, then you can use something like this to get users without owner:
has_many :users, -> { where owner: false }, class_name: 'User'
Documentation: Scopes for has_many
Upvotes: 0