find champ by dossier stable_id row_id
This commit is contained in:
parent
fc385208db
commit
ebea9e3818
2 changed files with 9 additions and 2 deletions
|
@ -55,7 +55,7 @@ class Attachment::EditComponent < ApplicationComponent
|
||||||
end
|
end
|
||||||
|
|
||||||
def destroy_attachment_path
|
def destroy_attachment_path
|
||||||
attachment_path(champ: @champ)
|
attachment_path(dossier_id: champ&.dossier_id, stable_id: champ&.stable_id, row_id: champ&.row_id)
|
||||||
end
|
end
|
||||||
|
|
||||||
def attachment_input_class
|
def attachment_input_class
|
||||||
|
|
|
@ -21,11 +21,18 @@ class AttachmentsController < ApplicationController
|
||||||
@attachment.purge_later
|
@attachment.purge_later
|
||||||
flash.notice = 'La pièce jointe a bien été supprimée.'
|
flash.notice = 'La pièce jointe a bien été supprimée.'
|
||||||
|
|
||||||
@champ = Champ.find(params[:champ]) if params[:champ]
|
@champ = find_champ if params[:dossier_id]
|
||||||
|
|
||||||
respond_to do |format|
|
respond_to do |format|
|
||||||
format.turbo_stream
|
format.turbo_stream
|
||||||
format.html { redirect_back(fallback_location: root_url) }
|
format.html { redirect_back(fallback_location: root_url) }
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
private
|
||||||
|
|
||||||
|
def find_champ
|
||||||
|
dossier = policy_scope(Dossier).includes(:champs).find(params[:dossier_id])
|
||||||
|
dossier.champs.find_by(stable_id: params[:stable_id], row_id: params[:row_id])
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue