From 3a0f98ebea5f316c86b9f487b8a5f640c0b65f64 Mon Sep 17 00:00:00 2001 From: guange <8863824@gmail.com> Date: Tue, 19 Jan 2016 15:17:56 +0800 Subject: [PATCH] =?UTF-8?q?openid=E5=87=BA=E9=94=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/wechats_controller.rb | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/app/controllers/wechats_controller.rb b/app/controllers/wechats_controller.rb index 7f589124d..3cf0664e4 100644 --- a/app/controllers/wechats_controller.rb +++ b/app/controllers/wechats_controller.rb @@ -118,7 +118,7 @@ class WechatsController < ActionController::Base on :fallback, respond: 'fallback message' on :click, with: 'MY_NEWS' do |request, key| - if user_binded? + if user_binded?(request[:FromUserName]) news = (1..count.to_i).each_with_object([]) { |n, memo| memo << { title: 'News title', content: "No. #{n} news content" } } request.reply.news(news) do |article, n, index| # article is return object article.item title: "#{index} #{n[:title]}", description: n[:content], pic_url: 'http://www.baidu.com/img/bdlogo.gif', url: 'http://www.baidu.com/' @@ -156,8 +156,7 @@ class WechatsController < ActionController::Base end private - def user_binded? - openid = request[:FromUserName] + def user_binded?(openid) uw = UserWechat.where(openid: openid).first end end