Skip to content

Instantly share code, notes, and snippets.

@staycreativedesign
Created October 25, 2017 17:34
Show Gist options
  • Save staycreativedesign/36b5c59110c30d245da2b80a5902b2e4 to your computer and use it in GitHub Desktop.
Save staycreativedesign/36b5c59110c30d245da2b80a5902b2e4 to your computer and use it in GitHub Desktop.
# So this is what I want to have happen
# first it checks if the current sponsor has 4 or more sponsored teams
# if he does it goes down to the his first sponsored coaches,
# if THAT coach has 4 or more sponsored teams it goes to the 2nd sponsored coach
def check_to_if_sponsor_count(new_team)
if new_team.sponsor.sponsored_teams.count >= 4
add_team_to_new_sponsor(new_team)
raise "full"
end
end
def add_team_to_new_sponsor(new_team)
u = new_team.sponsor
c = u.sponsored_teams.first.coach
c.sponsored_teams << new_team
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment