增加《不区分大小写分班班名唯一》功能

Signed-off-by: alan <547533434@qq.com>
This commit is contained in:
alan 2014-12-10 18:40:04 +08:00
parent 90a01c8d84
commit 66d76eeed7
1 changed files with 2 additions and 1 deletions

View File

@ -12,7 +12,8 @@ class CourseGroup < ActiveRecord::Base
before_destroy :set_member_nil
attr_accessible :name
validates :name, :presence => true, :length => {:maximum => 20}, :uniqueness => true
validates :name, :presence => true, :length => {:maximum => 20},
:uniqueness => {case_sensitive: false}
def set_member_nil
if self.members && self.members.count > 0
self.members.update_all("course_group_id = 0")