fix: change owner must fix foreign_key
This commit is contained in:
		
							parent
							
								
									000197b0d1
								
							
						
					
					
						commit
						a6cee63d17
					
				| 
						 | 
				
			
			@ -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
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -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
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -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)}"
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
		Reference in New Issue