Guest User

Untitled

a guest
Jun 21st, 2018
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.73 KB | None | 0 0
  1. class Entity < ActiveRecord::Base
  2. has_many :relationships, :foreign_key => "left_id"
  3. has_many :relationships, :foreign_key => "right_id"
  4. has_many :rights, :through => :relationships
  5. has_many :lefts, :through => :relationships
  6. end
  7.  
  8. class Individual < Entity
  9. end
  10.  
  11. class Organisation < Entity
  12. end
  13.  
  14. class Relationship < ActiveRecord::Base
  15. has_one :relationshiptypes
  16. belongs_to :left, :class_name => "Entity", :foreign_key => "left_id"
  17. belongs_to :right, :class_name => "Entity", :foreign_key => "right_id"
  18. validates_uniqueness_of :left_id, :scope => [:right_id, :relationshiptypes_id], :message => "This relationship already exists"
  19. end
  20.  
  21. class Relationshiptype < ActiveRecord::Base
  22. belongs_to :relationships
  23. end
Add Comment
Please, Sign In to add comment