22 lines
636 B
Ruby
22 lines
636 B
Ruby
# status 控制实训的状态,0:未开启;1: 已开启(TPM); 2:已认证
|
||
class Shixun < ActiveRecord::Base
|
||
attr_accessible :description, :is_public, :name, :changeset_num, :status, :user_id, :gpid, :language, :identifier, :authentication, :myshixun_count
|
||
|
||
has_many :users, :through => :shixun_members
|
||
has_many :shixun_members
|
||
has_one :repository
|
||
has_many :challenges, :dependent => :destroy, :order => "challenges.id ASC"
|
||
has_many :myshixuns
|
||
|
||
# id 转换成 identifier
|
||
def to_param
|
||
identifier
|
||
end
|
||
|
||
def owner
|
||
User.find(self.user_id)
|
||
rescue ActiveRecord::RecordNotFound
|
||
render_404
|
||
end
|
||
end
|