Sunday, May 2, 2010

To Boldly Go Where No Man(Me) Has Gone Before

Captain's log, Stardate 542010.5.

I've been working on my project for week's. The past couple days have been uneventful but I've made excellent progress. I am figuring out the relationships between League, Game, Player, and Stat. I've been learning about nesting resources and nesting models in one form. I've split them into pairs.

League has many Games. Game belongs to League.
Player has many Stats. Stat belongs to Player.

This gives me these routes.

/leagues
/leagues/:id
/leagues/:league_id/games
/leagues/:league_id/games/:id
/players
/players/:id
/players/:player_id/stats
/players/:player_id/stats/:id

Now I am able to create a league with many games and players with many stats. I'm working on getting the players with their stats to belong to a specific game in a specific league. I want to access players on its own so I'm hesitant to nest it. Plus, Rule of thumb: resources should never be nested more than 1 level deep. So I shouldn't do Games to Players to Stats.

I would like to have the form below to create the box score for each game. It will also track each players stats.
It would start with a drop-down menu to choose league. Selecting a league will activate the drop-down menu of games in that league. Selecting a game will do something that will allow me to get the form to choose a player from a drop-down menu and add their stats for that game. And do this for multiple players.

When I view the game I see


May the force be with you.

No comments: