Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 1898330
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T06:45:07+00:00 2026-05-17T06:45:07+00:00

I am attempting to model a table tennis match in rails. Here is what

  • 0

I am attempting to model a table tennis match in rails. Here is what I have:

Game Model:
team_1_score
team_2_score
team_1_id
team_2_id

Team Model:
game_id
player_id

Player Model:
Name

So each game will consist of 2 teams (of either 1 or 2 players each).
Then I was planning on linking game to player with has_many, :through. I don’t think this will work because of the 2 instances of team in each game. But I really don’t know where I should go from here. Any help would be greatly appreciated.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-17T06:45:07+00:00Added an answer on May 17, 2026 at 6:45 am

    I’m not sure how to do the has_many :through between players and games, but it might be easier if you start out with something like this:

    Team Model
    id
    name
    has_many :players
    has_many :games
    
    Player Model
    id
    name
    team_id 
    has_one :team
    

    Then the Games model would have something like (in addition to what you already have):

    has_one :team1, :class_name => 'Team'
    has_one :team2, :class_name => 'Team'
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm new to Rails and I'm attempting to do the following, but I have
I have a table containing about 30k records, that I'm attempting to iterate over
I'm attempting to design an achievement system in Ruby on Rails and have run
I'm attempting to model responses from REST APIs as case classes which I can
I'm attempting to perform a DML operation against an Entity Framework model, specifically, an
so django-model-utils is awesome. I'm on django 1.3 and attempting to use the Inheritance
Attempting to build a C# NPAPI plugin I have found a tutorial which describes
Attempting to get Spring internationalization working. I have used classpath:messages basename, created .properties files
I've created a model with MySQL Workbench and am now attempting to install it
I'm attempting to extend django's contrib.auth User model, using an inline 'Profile' model to

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.