Skip to content

Instantly share code, notes, and snippets.

@monkbroc
Created April 9, 2015 16:44
Show Gist options
  • Select an option

  • Save monkbroc/8eb576068f886688ef4a to your computer and use it in GitHub Desktop.

Select an option

Save monkbroc/8eb576068f886688ef4a to your computer and use it in GitHub Desktop.
Updated models
class Team < ActiveRecord::Base
has_many :team_users
has_many :users, :through => :team_users
end
class TeamUser < ActiveRecord::Base
# Validations
validates_presence_of :team, :user
# Relations
belongs_to :user
belongs_to :team
end
class User < ActiveRecord::Base
has_many :team_users
has_many :teams, :through => :team_users
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment