From b85d951651088e86e548e875886ae99a48e2e061 Mon Sep 17 00:00:00 2001 From: Paul Bob Date: Sat, 28 Sep 2024 21:15:57 +0300 Subject: [PATCH] extract url from associations view to controller --- app/controllers/avo/associations_controller.rb | 10 ++++++++++ app/views/avo/associations/new.html.erb | 13 +------------ 2 files changed, 11 insertions(+), 12 deletions(-) diff --git a/app/controllers/avo/associations_controller.rb b/app/controllers/avo/associations_controller.rb index 5b1800781..a0f2df220 100644 --- a/app/controllers/avo/associations_controller.rb +++ b/app/controllers/avo/associations_controller.rb @@ -64,6 +64,16 @@ def new [@attachment_resource.new(record: record).record_title, record.to_param] end end + + @url = Avo::Services::URIService.parse(avo.root_url.to_s) + .append_paths('resources', params[:resource_name], params[:id], params[:related_name]) + .append_query( + { + view: @resource&.view&.to_s, + for_attribute: @field&.try(:for_attribute) + }.compact + ) + .to_s end def create diff --git a/app/views/avo/associations/new.html.erb b/app/views/avo/associations/new.html.erb index 7061b865c..bffa165a7 100644 --- a/app/views/avo/associations/new.html.erb +++ b/app/views/avo/associations/new.html.erb @@ -1,17 +1,6 @@ <%= turbo_frame_tag Avo::MODAL_FRAME_ID do %> - <% - url = Avo::Services::URIService.parse(avo.root_url.to_s) - .append_paths('resources', params[:resource_name], params[:id], params[:related_name]) - .append_query( - { - view: @resource&.view&.to_s, - for_attribute: @field&.try(:for_attribute) - }.compact - ) - .to_s - %> <%= form_with scope: 'fields', - url: url, + url: @url, local: true, data: { turbo_frame: :_top