You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
pgfqe6ch8/app/models/user_wechat.rb

33 lines
923 B

class UserWechat < ActiveRecord::Base
attr_accessible :subscribe, :openid, :nickname, :sex, :language, :city, :province, :country,
:headimgurl, :subscribe_time, :unionid, :remark, :groupid, :user, :user_id, :bindtype
belongs_to :user
def real?
bindtype == 0
end
def migrate_user(u)
self.bindtype = 0
old_user = user.id
self.user = u
self.save
## 主要是将comment 迁移
User.delete(old_user)
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)
BlogComment.where(author_id: old_user).update_all(author_id: u.id)
UserActivity.where(user_id: old_user).update_all(user_id: u.id)
end
def unsubscribe!
self.delete
end
end