diff --git a/app/controllers/projects_controller.rb b/app/controllers/projects_controller.rb index c4e440aff..8bc2fb476 100644 --- a/app/controllers/projects_controller.rb +++ b/app/controllers/projects_controller.rb @@ -209,7 +209,7 @@ class ProjectsController < ApplicationController end def fork_users - fork_users = @project.fork_users.includes(:user, :project, :fork_project).order("fork_users.created_at desc").distinct + fork_users = @project.fork_users.includes(:owner, :project, :fork_project).order("fork_users.created_at desc").distinct @forks_count = fork_users.size @fork_users = paginate(fork_users) end diff --git a/app/models/fork_user.rb b/app/models/fork_user.rb index 4177392ee..2d74af4a4 100644 --- a/app/models/fork_user.rb +++ b/app/models/fork_user.rb @@ -17,7 +17,7 @@ class ForkUser < ApplicationRecord belongs_to :project - belongs_to :owner + belongs_to :owner, class_name: 'Owner', foreign_key: :user_id belongs_to :fork_project, class_name: 'Project', foreign_key: :fork_project_id after_create :incre_project_common, :incre_user_statistic, :incre_platform_statistic diff --git a/app/views/projects/fork_users.json.jbuilder b/app/views/projects/fork_users.json.jbuilder index f5147e19e..730576c16 100644 --- a/app/views/projects/fork_users.json.jbuilder +++ b/app/views/projects/fork_users.json.jbuilder @@ -1,7 +1,7 @@ json.count @forks_count json.users do json.array! @fork_users.each do |f| - user = f.user.present? ? f.user : Organization.find_by(id: f.user_id) + user = f.owner.present? ? f.owner : Organization.find_by(id: f.user_id) json.id f.fork_project.id json.identifier f.fork_project.identifier json.name "#{user.try(:show_real_name)}/#{f.fork_project.try(:name)}"