I am curious how this works ... I have several has_many relationships between the same two models. This is a calendar application, so the user can be invited to an event, the user can attend the event, and the event belongs to the user to view who created this event.
user.rb
class User < ActiveRecord::Base
has_many :invites, dependent: :destroy
has_many :events, through: :invites
has_many :events
has_many :attendances, -> { where cancel: false },
dependent: :destroy
has_many :events, -> { where "attendances.cancel" => false },
through: :attendances
event.rb
class Event < ActiveRecord::Base
has_many :invites, dependent: :destroy
has_many :users, through: :invites
belongs_to :user
has_many :attendances, -> { where cancel: false },
dependent: :destroy
has_many :users, -> { where "attendances.cancel" => false },
through: :attendances
I also have matching connection tables managed in their respective models, attendance.rband invite.rb.
... , . , . , , , . , , , , - User.find(1).events.
? , , ?