|
|
|
@ -38,6 +38,7 @@ class Course < ActiveRecord::Base
|
|
|
|
|
validates_format_of :class_period, :with =>/^[1-9]\d*$/
|
|
|
|
|
validates_format_of :name,:with =>/^[a-zA-Z0-9_\u4e00-\u9fa5]+$/
|
|
|
|
|
|
|
|
|
|
before_save :self_validate
|
|
|
|
|
after_save :create_board_sync
|
|
|
|
|
before_destroy :delete_all_members
|
|
|
|
|
|
|
|
|
@ -77,7 +78,7 @@ class Course < ActiveRecord::Base
|
|
|
|
|
where(nil)
|
|
|
|
|
else
|
|
|
|
|
pattern = "%#{arg.to_s.strip.downcase}%"
|
|
|
|
|
where("LOWER(extra) LIKE :p OR LOWER(name) LIKE :p ", :p => pattern)
|
|
|
|
|
where(" LOWER(name) LIKE :p ", :p => pattern)
|
|
|
|
|
end
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -166,10 +167,8 @@ class Course < ActiveRecord::Base
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
#自定义验证
|
|
|
|
|
def validate
|
|
|
|
|
if !class_period.match([0-9])
|
|
|
|
|
errors.add_to_base("class period can only digital")
|
|
|
|
|
end
|
|
|
|
|
def self_validate
|
|
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
# 创建课程讨论区
|
|
|
|
|