Sha256: 9b75d7e9d6ac44e6536ce45685144fa6c23afdc287238e175ffbbd9302c6c833
Contents?: true
Size: 1.65 KB
Versions: 4
Compression:
Stored size: 1.65 KB
Contents
module SportDb module Model class Assoc < ActiveRecord::Base has_many :parent_assoc_assocs, class_name: 'AssocAssoc', foreign_key: 'assoc2_id' ## child_assocs - use child_assocs? - (direct) member/child assocs instead of member? has_many :member_assoc_assocs, class_name: 'AssocAssoc', foreign_key: 'assoc1_id' ## note: split member_assocs into two sets (into national=true and national=false) # e.g. fifa has six member confederations (non-national) and 216 national assocs ## note: includes all member (sub assocs + national assocs) - rename to member_assocs? has_many :all_assocs, class_name: 'Assoc', :source => :assoc2, :through => :member_assoc_assocs ## use zone/region as name instead of sub ( for confederatons,zones,etc.) has_many :sub_assocs, -> { where( national: false ) }, class_name: 'Assoc', :source => :assoc2, :through => :member_assoc_assocs has_many :national_assocs, -> { where( national: true ) }, class_name: 'Assoc', :source => :assoc2, :through => :member_assoc_assocs ## for now can have more than one (direct) parent assoc ## e.g. Africa Fed and Arab League Fed has_many :parent_assocs, class_name: 'Assoc', :source => :assoc1, :through => :parent_assoc_assocs # assoc only can have one direct team for now (uses belongs_to on other side) # has_one :team end # class Assoc class AssocAssoc < ActiveRecord::Base self.table_name = 'assocs_assocs' belongs_to :assoc1, class_name: 'Assoc', foreign_key: 'assoc1_id' # parent assoc belongs_to :assoc2, class_name: 'Assoc', foreign_key: 'assoc2_id' # child assoc is_member_of parent assoc end # class AssocAssoc end # module Model end # module SportDb
Version data entries
4 entries across 4 versions & 1 rubygems