Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class Entity < ActiveRecord::Base
- has_many :relationships, :foreign_key => "left_id"
- has_many :relationships, :foreign_key => "right_id"
- has_many :rights, :through => :relationships
- has_many :lefts, :through => :relationships
- end
- class Individual < Entity
- end
- class Organisation < Entity
- end
- class Relationship < ActiveRecord::Base
- has_one :relationshiptypes
- belongs_to :left, :class_name => "Entity", :foreign_key => "left_id"
- belongs_to :right, :class_name => "Entity", :foreign_key => "right_id"
- validates_uniqueness_of :left_id, :scope => [:right_id, :relationshiptypes_id], :message => "This relationship already exists"
- end
- class Relationshiptype < ActiveRecord::Base
- belongs_to :relationships
- end
Add Comment
Please, Sign In to add comment