2013-01-25 10:50:53 +00:00
|
|
|
class UserCertification < ActiveRecord::Base
|
|
|
|
attr_accessible :certification_id, :user_id
|
2013-01-25 13:01:02 +00:00
|
|
|
|
2013-08-27 06:01:43 +00:00
|
|
|
validates_presence_of :certification_id, :user_id
|
2013-01-25 13:01:02 +00:00
|
|
|
validates_uniqueness_of :certification_id, :scope => :user_id, :message => 'already exists for this user.' # Makes sure users don't get certified twice
|
|
|
|
|
2013-01-25 10:50:53 +00:00
|
|
|
belongs_to :user
|
|
|
|
belongs_to :certification
|
2013-08-24 09:23:12 +00:00
|
|
|
|
|
|
|
def user_name
|
|
|
|
if user.blank?
|
|
|
|
return "n/a (user ##{user_id} missing)"
|
|
|
|
else
|
|
|
|
return self.user.name
|
|
|
|
end
|
|
|
|
end
|
2013-01-25 10:50:53 +00:00
|
|
|
end
|