越过course表的validate,以防save invitecode 失败

This commit is contained in:
guange 2016-06-28 19:19:59 +08:00
parent 7fdfc02821
commit 222855ea79
2 changed files with 6 additions and 3 deletions

View File

@ -3,7 +3,11 @@ source 'https://ruby.taobao.org/'
unless RUBY_PLATFORM =~ /w32/
# unix-like only
gem 'iconv'
gem "rmagick", "= 2.13.1" ## centos yum install ImageMagick-devel
if RUBY_PLATFORM =~ /darwin/
gem "rmagick", "= 2.15.4" ## osx must be this version
else
gem "rmagick", "= 2.13.1" ## centos yum install ImageMagick-devel
end
gem 'certified'
end

View File

@ -470,8 +470,7 @@ class Course < ActiveRecord::Base
if !code || code.size <5
code = CODES.sample(5).join
return generate_invite_code if Course.where(invite_code: code).present?
self[:invite_code] = code
save! && reload
update_attribute(:invite_code, code)
end
code
end