修改watcher

This commit is contained in:
sylor_huang@126.com 2020-06-05 18:36:33 +08:00
parent 88d2f1d07f
commit fbf2738bd1
4 changed files with 10 additions and 4 deletions

View File

@ -71,7 +71,7 @@ class User < ApplicationRecord
has_many :be_watchers, foreign_key: :user_id, dependent: :destroy # 我的关注
has_many :be_watcher_users, through: :be_watchers, dependent: :destroy # 我关注的用户
has_many :watchers, dependent: :destroy
has_many :watchers, as: :watchable, dependent: :destroy
# 认证
has_many :apply_user_authentication

View File

@ -1,4 +1,4 @@
user = target.watchable
# user = target.watchable
json.format_time target.created_at.strftime("%Y-%m-%d")
json.name user.try(:show_real_name)

View File

@ -1,4 +1,7 @@
json.count @watchers_count
json.users do
json.partial! "/users/watch_user_detail", collection: @watchers, as: :target
json.array! @watchers do |watcher|
json.partial! "/users/watch_user_detail", locals: {target: watcher, user: target.user}
end
# json.partial! "/users/watch_user_detail", collection: @watchers, as: :target
end

View File

@ -1,4 +1,7 @@
json.count @watchers_count
json.users do
json.partial! "/users/watch_user_detail", collection: @watchers, as: :target
json.array! @watchers do |watcher|
json.partial! "/users/watch_user_detail", locals: {target: watcher, user: watcher.watchable}
end
# json.partial! "/users/watch_user_detail", collection: @watchers, as: :target
end