Skip to content

Commit

Permalink
ISSUE #448: Correção no update do conceito CAPES
Browse files Browse the repository at this point in the history
  • Loading branch information
IgorMonardez committed Oct 24, 2024
1 parent af1ff0f commit 3b6452c
Showing 1 changed file with 10 additions and 14 deletions.
24 changes: 10 additions & 14 deletions app/controllers/program_levels_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,23 +17,19 @@ class ProgramLevelsController < ApplicationController

protected
def do_update
# BEFORE UPDATE
# cria o histórico

pl = ProgramLevel.last
unless pl.nil?
ProgramLevel.create!(
level: pl.level,
start_date: pl.start_date,
end_date: Time.now
)
end
old_record = ProgramLevel.find_by_id(params[:id])

super
# AFTER UPDATE
# atualiza a data de início

pl = ProgramLevel.last
pl.update!(start_date: pl.updated_at)
record = self.params[:record]

if old_record.level != record[:level]
ProgramLevel.create!(
level: old_record.level,
start_date: old_record.start_date,
end_date: record[:start_date]
)
end
end
end

0 comments on commit 3b6452c

Please sign in to comment.