Skip to content

Instantly share code, notes, and snippets.

@alfie-max
Created July 28, 2016 13:25
Show Gist options
  • Save alfie-max/58dd07e53988fa4ea39c1141c3462ca5 to your computer and use it in GitHub Desktop.
Save alfie-max/58dd07e53988fa4ea39c1141c3462ca5 to your computer and use it in GitHub Desktop.
class User < ActiveRecord::Base
has_many :events, foreign_key: :chef_id, dependent: :destroy
has_many :reservations, foreign_key: :guest_id
has_many :guest_events, -> { merge(Reservation.accepted) },
through: :reservations, source: :event
has_many :all_guest_events, through: :reservations, source: :event
has_many :event_notifications, -> { uniq }, through: :all_guest_events,
source: :notifications
has_many :notifications
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment