This commit is contained in:
Jason Denney
2012-12-04 00:46:15 -05:00
commit aa3ed3d43b
97 changed files with 2398 additions and 0 deletions
+18
View File
@@ -0,0 +1,18 @@
class TeamMembership < ActiveRecord::Base
belongs_to :team
belongs_to :user
validates :user, :presence => true
validates :team, :presence => true
validates :user_id, :uniqueness => { :scope => :team_id }
validate :no_captains_allowed
private
def no_captains_allowed
if user.present? && team.present? && team.captain == user
errors.add(:user, "Captain is already a member.")
end
end
end