2013-09-06 16:40:07 +08:00
|
|
|
|
class Course < ActiveRecord::Base
|
|
|
|
|
include Redmine::SafeAttributes
|
|
|
|
|
|
2013-09-28 23:08:24 +08:00
|
|
|
|
attr_accessible :code, :extra, :name, :state, :tea_id, :time , :location, :state, :term, :password
|
2013-09-23 08:44:48 +08:00
|
|
|
|
belongs_to :project, :class_name => 'Project', :foreign_key => :extra # 定义一个project方法, 该方法通过extra来调用project表
|
2013-09-14 17:25:57 +08:00
|
|
|
|
belongs_to :teacher, :class_name => 'User', :foreign_key => :tea_id # 定义一个方法teacher,该方法通过tea_id来调用User表
|
2013-09-06 16:40:07 +08:00
|
|
|
|
has_many :bid
|
2013-09-28 23:08:24 +08:00
|
|
|
|
validates_presence_of :password, :term
|
2013-09-06 16:40:07 +08:00
|
|
|
|
safe_attributes 'extra',
|
|
|
|
|
'time',
|
|
|
|
|
'name',
|
|
|
|
|
'extra',
|
2013-09-12 10:41:15 +08:00
|
|
|
|
'code',
|
2013-09-12 17:25:40 +08:00
|
|
|
|
'location',
|
|
|
|
|
'tea_id',
|
2013-09-28 23:08:24 +08:00
|
|
|
|
'password',
|
2013-09-29 19:46:59 +08:00
|
|
|
|
'term',
|
|
|
|
|
'password'
|
2013-09-12 10:41:15 +08:00
|
|
|
|
|
2013-09-06 16:40:07 +08:00
|
|
|
|
|
|
|
|
|
end
|