educoder/app/models/shixun.rb

22 lines
636 B
Ruby
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# 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