Browse Source

修改watcher

tags/v1
sylor_huang@126.com 6 years ago
parent
commit
fbf2738bd1
4 changed files with 10 additions and 4 deletions
  1. +1
    -1
      app/models/user.rb
  2. +1
    -1
      app/views/users/_watch_user_detail.json.jbuilder
  3. +4
    -1
      app/views/users/fan_users.json.jbuilder
  4. +4
    -1
      app/views/users/watch_users.json.jbuilder

+ 1
- 1
app/models/user.rb 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


+ 1
- 1
app/views/users/_watch_user_detail.json.jbuilder 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)


+ 4
- 1
app/views/users/fan_users.json.jbuilder 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

+ 4
- 1
app/views/users/watch_users.json.jbuilder 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

Loading…
Cancel
Save