diff --git a/app/api/mobile/apis/users.rb b/app/api/mobile/apis/users.rb index 96cec7b39..62376dc6e 100644 --- a/app/api/mobile/apis/users.rb +++ b/app/api/mobile/apis/users.rb @@ -37,7 +37,7 @@ module Mobile raise "此用户已经绑定过公众号, 请换一个帐户试试" if user.user_wechat - if uw && !user.real? + if uw && !uw.real? uw.migrate_user(user) else UserWechat.create!( @@ -69,7 +69,7 @@ module Mobile :should_confirmation_password => true) raise user.errors.full_messages.first if user.new_record? - if uw && !user.real? + if uw && !uw.real? user.update_attributes(:lastname=>uw.user[:lastname]) uw.migrate_user(user) else diff --git a/app/controllers/wechats_controller.rb b/app/controllers/wechats_controller.rb index fbd1f2f0c..ced8854d9 100644 --- a/app/controllers/wechats_controller.rb +++ b/app/controllers/wechats_controller.rb @@ -252,13 +252,16 @@ class WechatsController < ActionController::Base end def sendBind(request) + tmpurl = "https://open.weixin.qq.com/connect/oauth2/authorize?appid=#{Wechat.config.appid}&redirect_uri=#{ROOT_URL+'/wechat/user_activities'}&response_type=code&scope=snsapi_base&state=login&connect_redirect=1#wechat_redirect" + logger.info "tmpurl!!!!!!!!!!!!!!" + logger.info tmpurl news = (1..1).each_with_object([]) { |n, memo| memo << { title: '绑定登录', content: "欢迎使用Trustie创新实践服务平台! 在这里您可以随时了解您的课程和项目动态,随时点赞和回复。 我们将会与微信不断结合,为您提供更有价值的服务。 您还未绑定确实的用户,请先绑定,谢谢!" } } request.reply.news(news) do |article, n, index| # article is return object - url = "https://open.weixin.qq.com/connect/oauth2/authorize?appid=#{Wechat.config.appid}&redirect_uri=#{ROOT_URL+'/wechat/user_activities'}&response_type=code&scope=snsapi_base&state=login#wechat_redirect" + url = tmpurl pic_url = "#{ROOT_URL}/images/weixin_pic.jpg" article.item title: "#{n[:title]}", description: n[:content], diff --git a/app/models/user_wechat.rb b/app/models/user_wechat.rb index a96cabbe5..8328a47df 100644 --- a/app/models/user_wechat.rb +++ b/app/models/user_wechat.rb @@ -15,9 +15,9 @@ class UserWechat < ActiveRecord::Base self.save ## 主要是将comment 迁移 - User.delete(old_user) + User.delete(old_user) - JournalForMessages.where(user_id: old_user).update_all(user_id: u.id) + JournalsForMessage.where(user_id: old_user).update_all(user_id: u.id) Journal.where(user_id: old_user).update_all(user_id: u.id) Comment.where(author_id: old_user).update_all(author_id: u.id) Message.where(author_id: old_user).update_all(author_id: u.id)