Fix bug regarding finding old_position
This commit is contained in:
parent
243ba2de3e
commit
813c2ba202
2 changed files with 8 additions and 4 deletions
|
|
@ -82,9 +82,11 @@ class Api::V1::JobsController < Api::V1::ApiController
|
|||
if !existing_skills[position]
|
||||
existing_skills[position] = skill
|
||||
else
|
||||
old_position = existing_skills.key(existing_skills.detect { |_, value| value.id == skill.id })
|
||||
value = existing_skills.detect { |_, value| value.id == skill.id }
|
||||
old_position = existing_skills.key(value[1]) if value
|
||||
|
||||
if old_position
|
||||
existing_skills = swap_skills_at_position(existing_skills, skill, position, old_position[0])
|
||||
existing_skills = swap_skills_at_position(existing_skills, skill, position, old_position)
|
||||
else
|
||||
# Test if skill will exceed allowances of skill types
|
||||
skill_type = skill.sub ? 'sub' : 'emp'
|
||||
|
|
|
|||
|
|
@ -1,4 +1,6 @@
|
|||
class JobSkill < ApplicationRecord
|
||||
alias eql? ==
|
||||
|
||||
include PgSearch::Model
|
||||
|
||||
belongs_to :job
|
||||
|
|
@ -25,7 +27,7 @@ class JobSkill < ApplicationRecord
|
|||
skill.name_en
|
||||
end
|
||||
|
||||
def ==(other)
|
||||
self.class == other.class && @id == other.id
|
||||
def ==(o)
|
||||
self.class == o.class && id == o.id
|
||||
end
|
||||
end
|
||||
|
|
|
|||
Loading…
Reference in a new issue