Jump to content

The ultimate community for Ruby on Rails developers.


Help on structure of my app

structure getting started confused

  • Please log in to reply
No replies to this topic

#1 jamesmarkcook



  • Members
  • 1 posts

Posted 06 May 2014 - 04:12 PM



I have started creating a Rails app to track games and scores and present results in a league format.


The games I have are Pool, Table Football, Table Tennis and FIFA for PS4. I have set up player accounts using Devise and decided what models I think I'm going to need, but I have run into problems when trying to get it all to work.


Here's where I am at the moment:


The models I anticipate needing for now are:


- Player (set up using Devise)

- Game (A game result)

- GameType (FIFA, table tennis etc)

- Score (individual scores for each game result and player)


The way I see the relationships working are like this:



has_and_belongs_to_many Games

has_many Scores



has_and_belongs_to_many Players

has_many Scores

belongs_to GameType



has_many Games



belongs_to Player

belongs_to Game


I have successfully 'created' a game but my main sticking point is how to create the Scores at the same time so that they belong to the Game, get associated to the correct players, and can be read out again if I were to edit the game. Should I do the Score creation and association in the Game controller, or on the Game model?


My instincts tell me that the model is the correct way of creating Scores on Game creation using virtual parameters, but this is proving extremely tricky for me and I'd just some advice on how other people would set this up?


Many thanks!




Also tagged with one or more of these keywords: structure, getting started, confused

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users