Objects and Relations in Ruby on Rails -


I am trying to create a simple web application for some personal development, but I have participated in an obstacle, Which I 'm hoping others will find despised are the classes I have to work with, but I am not sure how to define their relationships, or their models are also appropriate.

For logic, I already existed: Users, teams, and athlete

I have the functionality I want to make a team by adding an athlete in the team object to another user, otherwise the other users can either add players to the team, or they can add an option to an existing athlete on the team roster. Basically, I am one of the athlete objects Something to wrap the array I want to make a square of R, we call it athlete's

If my understanding is correct, then there are relationships which will be appropriate:

  1. A team - many athletes
  2. will be an athlete - < / Em> athlete and a team
  3. athlete related < Strong> users , and related a athlete .
  4. Users - Many athletes, but this will be the limit of their involvement.

Since the athlete's category does not have any special properties, it will therefore have an ActiveRecord object (this will only be an ID)? Is there another way to implement this idea (can you define team squares, for the array of athlete objects)? I have little knowledge of ROR, but I thought it would be a good place to start with web development. Any help would be appreciated. thank you in advanced!

Edit: The names of athletes, teams and athletes are unimportant. Suppose the athlete is basically a comment, which is valid against the list of athletes. Repetition is acceptable. If I understand the answers, then I should basically make the intermediate class, who recognize my parents?

Omar's reaction is: finally, I want to add a voting system. Therefore, after creating a basic team, users can individually suggest replacement for a given player and users can opt for the best option. For example, if I have a team of chess players:

  1. Bobby Fisher
  2. Gary Kasparov
  3. Vladimir Kramnik

Someone can click on Casparov and decide that the better athlete will be Deep Blue, so this option will be nested under Casparov unless it receives more votes. This is the same process for each character, but unlike a comment system, you will not be able to answer "Deep Blue" and will replace the other player, you will only respond to position number 2 and suggest another player Will give

Some stop here, maybe in the naming of your model. The smell of athlete's juice is not very well liked.

is_my_through You may need to reach the athletes from your team. E.g.

  is_im: athletes, through: = & gt; : Team_permuations # Your athletearaya model  

There is an old round of many organizations of Josh Susser, which I think is what you want, because according to your specification, theoretically it is for an athlete It is possible that in any number of teams I think that the best thing is that you can populate the audit columns (made / updated_at / on) on many of your organizations, which is a good thing.

Please comment if you think I have understood the wrong question.


Comments

Popular posts from this blog

c++ - Linux and clipboard -

Visual Studio 2005: How to speed up builds when a VSMDI is open? -

booting ubuntu from usb using virtualbox -