Open-Source-Access-Control-.../app/models/user_certification.rb
Will Bradley accec4edb1 Merge branch 'csv'
Conflicts:
	app/models/user_certification.rb
	app/views/user_certifications/index.html.erb
	app/views/user_certifications/show.html.erb
2013-08-28 08:21:28 -07:00

18 lines
488 B
Ruby

class UserCertification < ActiveRecord::Base
attr_accessible :certification_id, :user_id
validates_presence_of :certification_id, :user_id
validates_uniqueness_of :certification_id, :scope => :user_id, :message => 'already exists for this user.' # Makes sure users don't get certified twice
belongs_to :user
belongs_to :certification
def user_name
if user.blank?
return "n/a (user ##{user_id} missing)"
else
return self.user.name
end
end
end