Since you have an additional field in the connection table, you will need a join model. Check this:
class User has_many :invitations has_many :invited_events, -> {where(confirmed: false)}, class_name: 'Event', through: :invitations has_many :confirmed_events, -> {where(confirmed: true)}, class_name: 'Event', through: :invitations end class Event has_many :invitations has_many :invited_users, -> {where(confirmed: false)}, class_name: 'User', through: :invitations has_many :confirmed_users, -> {where(confirmed: true)}, class_name: 'User', through: :invitations end class Invitation belongs_to :user belongs_to :event end
In this case, user.confirmed_events will provide user events only where the flag is set to true in the connection table.
source share