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

  • Home
  • SEARCH
  • 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 5840323
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T11:43:36+00:00 2026-05-22T11:43:36+00:00

I have been working on a project recently where a Player can create a

  • 0

I have been working on a project recently where a Player can create a Team and be the Team Owner, but a player as well can be part of the Team by a separate table, named Squad.

class Player
has_many :teams
has_many :squads
end

class Squad
belongs_to :player
belongs_to :team
end

class Team
belongs_to :owner, :class_name => "Player"
has_many :squads
has_many :players, :through => "squads"
end

I don’t know if this is all I need to make what I want, but I just can’t figure out. How can I make the player ask to be invited to the team via Squad, and the Owner of the Team answers yes or no to that player? If yes, he joins table Squad and is part of the team. If no, his request is destroyed.

  • 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-22T11:43:37+00:00Added an answer on May 22, 2026 at 11:43 am

    You need to make a boolean field status in your Squad model, that defaults to false. If you need something more complex, you could use this gem.

    So player invokes a squad#create action, it creates a squad model.
    Team#show shows the owner of the team join requests from players and use squad#accept or squad#reject (or #update with status argument) and then you change the status to true, or destroy this squad record.

    And basically that’s it

    Updated

    This is how a basic social network friending system works.

    With state_machine you could define another state rejected, so the same user doesn’t spam the team owner with requests after being rejected. By checking the updated_at field, you could implement a timeout, after which the same person could repeat his request.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have recently been working with someone on a project that is very ajax
I have been working with Struts for some time, but for a project I
On one project we have been working on recently, we have in essence totally
Recently I have been working on a project where, among other things, we want
So recently I have been working on phonebook project that uses Binary Search Tree.
I have been working on a project that has 2 interfaces - windows forms
I have been working on a Java project for a class for a while
I have been working on a web services related project for about the last
I have a project that I have been working on for a while, just
On a recent project I have been working on in C#/ASP.NET I have some

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.