Skip to content

Commit

Permalink
More elegant way
Browse files Browse the repository at this point in the history
  • Loading branch information
Eric-Guo committed Nov 14, 2024
1 parent f4b122c commit d82e1ca
Showing 1 changed file with 2 additions and 6 deletions.
8 changes: 2 additions & 6 deletions app/controllers/home_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,8 @@ class HomeController < ApplicationController

def index
@first_level_user_job_roles = current_user&.user_job_roles || []
@second_level_user_job_roles = []

@first_level_user_job_roles.each do |ujr|
ujr.managed_user_job_roles.each do |second_ujr|
@second_level_user_job_roles << second_ujr if second_ujr.managed_user_job_roles.present?
end
@second_level_user_job_roles = @first_level_user_job_roles.flat_map do |user_job_role|
user_job_role.managed_user_job_roles.select(&:managed_user_job_roles)
end
end

Expand Down

0 comments on commit d82e1ca

Please sign in to comment.