parent
0d6261dfa7
commit
a467736a5e
|
@ -12,8 +12,7 @@ class CourseGroup < ActiveRecord::Base
|
|||
before_destroy :set_member_nil
|
||||
|
||||
attr_accessible :name
|
||||
validates :name, :presence => true, :length => {:maximum => 20}
|
||||
validate :unique_name_and_course
|
||||
validates :name, :presence => true, :length => {:maximum => 20}, :uniqueness => { :scope => :course_id}
|
||||
|
||||
|
||||
|
||||
|
@ -22,10 +21,5 @@ class CourseGroup < ActiveRecord::Base
|
|||
self.members.update_all("course_group_id = 0")
|
||||
end
|
||||
end
|
||||
private
|
||||
def unique_name_and_course
|
||||
if CourseGroup.where("name=? and course_id=?", name, course_id).first
|
||||
errors.add(:name, :groupname_repeat)
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue