Created
September 27, 2012 04:02
-
-
Save JFickel/3792082 to your computer and use it in GitHub Desktop.
edit
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Note < ActiveRecord::Base | |
attr_accessible :description, :sender_id, :receivable_id | |
belongs_to :sender, class_name: "User" | |
belongs_to :receivable | |
end | |
class User < ActiveRecord::Base | |
has_many :notes, foreign_key: "sender_id", dependent: :destroy | |
has_many :outgoing_notes, through: :notes, source: :user_recipient | |
has_many :incoming_notes, as: :receivable , | |
class_name: "Note", | |
dependent: :destroy | |
has_many :received_notes, through: :incoming_notes, source: :sender | |
end | |
class Team < ActiveRecord::Base | |
has_many :incoming_notes, as: :receivable, | |
class_name: "Note", | |
dependent: :destroy | |
has_many :received_notes, through: :incoming_notes, source: :sender | |
end | |
class Tournament < ActiveRecord::Base | |
has_many :incoming_notes, as: :receivable, | |
class_name: "Note", | |
dependent: :destroy | |
has_many :received_notes, through: :incoming_notes, source: :sender | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment