refactor rna controller to use that new ability

This commit is contained in:
sebastiencarceles 2023-01-13 14:22:43 +01:00
parent 7d65a34bc6
commit 396ebbcf2b

View file

@ -4,13 +4,6 @@ class Champs::RNAController < ApplicationController
def show
@champ = policy_scope(Champ).find(params[:champ_id])
@rna = read_param_value(@champ.input_name, 'value')
@network_error = false
begin
data = APIEntreprise::RNAAdapter.new(@rna, @champ.procedure_id).to_params
@champ.update!(data: data, value: @rna)
rescue APIEntreprise::API::Error, ActiveRecord::RecordInvalid => error
@network_error = true if error.try(:network_error?) && !APIEntrepriseService.api_up?
@champ.update(data: nil, value: nil)
end
@network_error = @champ.fetch_association!(@rna).present?
end
end