I am currently working on an app for sporting clubs, this allows club admins to manage the divisions, teams, and ultimately the players.
At present I have my database/relationships as follows
class Sport < ActiveRecord::Base
has_many :clubs
has_many :teams
attr_accessible :club_id
class Club < ActiveRecord::Base
belongs_to :sport
has_many :teams
has_many :users
has_many :divisions
attr_accessible :sport_id
class Division < ActiveRecord::Base
has_many :teams
belongs_to :club
attr_accessible :club_id
class Team < ActiveRecord::Base
has_many :users
has_many :schedules
belongs_to :division
belongs_to :club
attr_accessible :division_id, :club_id
class User < ActiveRecord::Base
belongs_to :club
belongs_to :team
attr_accessiable :club_id, :sport_id
essential what I would like is a more concise way of managing this. i.e.
- User can only belong to 1 club, within 1 division, but can have multiple teams
- Team can only belong to 1 division, within 1 club, within 1 sport, but have multiple users
- Division can only belong to 1 club, within 1 sport, but have multiple teams
- Club can only belong to 1 sport, but have multiple teams, and multiple divisions
At present the above is working, but i dont think the relationships/structure is at its best