diff --git a/app/models/course.rb b/app/models/course.rb index 4b4313ee1..561a031ae 100644 --- a/app/models/course.rb +++ b/app/models/course.rb @@ -495,7 +495,7 @@ class Course < ActiveRecord::Base def generate_qrcode ticket = self.qrcode if !ticket || ticket.size < 10 - response = Wechat.api.qrcode_create_scene(invite_code) + response = Wechat.api.qrcode_create_scene(invite_code, 2592000) logger.debug "response = #{response}" self.qrcode = response['ticket'] save! && reload diff --git a/db/migrate/20160708091258_renew_qrcode.rb b/db/migrate/20160708091258_renew_qrcode.rb new file mode 100644 index 000000000..59f92b315 --- /dev/null +++ b/db/migrate/20160708091258_renew_qrcode.rb @@ -0,0 +1,8 @@ +class RenewQrcode < ActiveRecord::Migration + def up + Course.update_all(:qrcode => '') + end + + def down + end +end diff --git a/db/schema.rb b/db/schema.rb index 619ccb7bb..3a56c6af4 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -11,7 +11,7 @@ # # It's strongly recommended to check this file into your version control system. -ActiveRecord::Schema.define(:version => 20160630112733) do +ActiveRecord::Schema.define(:version => 20160708091258) do create_table "activities", :force => true do |t| t.integer "act_id", :null => false @@ -562,9 +562,9 @@ ActiveRecord::Schema.define(:version => 20160630112733) do t.integer "excellent_option", :default => 0 t.integer "is_copy", :default => 0 t.integer "visits", :default => 0 - t.integer "syllabus_id" t.string "invite_code" t.string "qrcode" + t.integer "syllabus_id" end add_index "courses", ["invite_code"], :name => "index_courses_on_invite_code", :unique => true