Skip to content

Add Tracker to a Team

Cory Boyd edited this page May 23, 2014 · 2 revisions

Hey Cory, can you add this Tracker to a Team?

Yeah!

HOW DOES WORK???!

Like this!

tracker = Tracker.find(47) # Bountysource.com
team = Team.find_by(slug: 'bountysource') # Bountysource, duh

# 1. Add the Tracker to the team. This relationship means "This is a Tracker that we use"
team.add_tracker(tracker)
# => #<TeamTrackerRelation id: 374, ... >

# 2. Set the Tracker owner to the Team. This means "This is a Tracker that we own"
tracker.update_attribute(:owner, team)
# => true

Revel in the glory that is your work: Glory

Clone this wiki locally