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 9253521
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T11:14:25+00:00 2026-06-18T11:14:25+00:00

I have the following Registration table : A player can Join multiple Match (like

  • 0

I have the following “Registration” table :

Inscription Table

A player can Join multiple Match (like in the picture, player #12 joined the match #59).

Now I would like to show all players who have registered to the same games as current_player.

So I though I had to :

  1. Catch all match_id where player_id = current_player
  2. Catch all the players in each match.

Is it the good way ? Or should I know something magic ? How can I do that ?
Thanks for your help.

UPDATE

I tried this :

@matchs_du_joueur = Registrations.where(:player_id => current_user.id)  

@joueurs = Player.joins(:registrations).where(:registrations => { :match_id => @matchs_du_joueur.match_id })

And I have this error :

undefined method `match_id' for #<ActiveRecord::Relation:0x6d8a3b0>

However, I have defined all the has_many_and_belongs_to .
Don’t know how to do.

  • 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-06-18T11:14:26+00:00Added an answer on June 18, 2026 at 11:14 am

    Yep, that’s it. I’m assuming

    class Match < ActiveRecord::Base
      has_many :registrations
      has_many :players, through: :registrations
    end
    
    class Player < ActiveRecord::Base
      has_many :registrations
      has_many :matches, through: :registrations
    end
    
    class Registration < ActiveRecord::Base
      belongs_to :match
      belongs_to :player
    end
    

    then you can just use the following to get all the players that the current_player has matches with

    Player.joins(:registrations).where(registrations: { match_id: current_player.match_ids })
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a registration page with the following code below: in the views: def
I am wondering how to do the following... I have a registration system. When
I have following div in a page (I can not modify). <div id=:0.control>Click me</div>
I have following question on adobe omniture How we can register an iPhone app
I have the following code in my registration page to go to a paypal
I have two relational tables, person and event_registration, and I would like to select
I have the following form as part of a registration process: <form class="form1" id="register_form1"
I have a registration form in my wordpress site. The following is the code
I have the following query that works when the Lookup table has something in
I am trying to create a simple registration form. I have the following: include('User.datatype.php');

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.