From 5c0468f8fd870e9a2d2b14a9f940fe1e14a0e361 Mon Sep 17 00:00:00 2001 From: guange <8863824@gmail.com> Date: Fri, 8 Jul 2016 17:18:09 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BA=8C=E7=BB=B4=E7=A0=81=E8=BF=87=E6=9C=9F?= =?UTF-8?q?=E6=94=B9=E4=B8=BA=E4=B8=80=E4=B8=AA=E6=9C=88=E6=9C=89=E6=95=88?= =?UTF-8?q?=E6=9C=9F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/models/course.rb | 2 +- db/migrate/20160708091258_renew_qrcode.rb | 8 ++++++++ db/schema.rb | 4 ++-- 3 files changed, 11 insertions(+), 3 deletions(-) create mode 100644 db/migrate/20160708091258_renew_qrcode.rb 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