Extract method for link to remove association text

We had an ultra-long line which was hard to read.
This commit is contained in:
Javi Martín
2021-09-11 17:11:36 +02:00
parent 507fa7c5f5
commit 7bbaad9a19

View File

@@ -31,7 +31,15 @@ class Attachable::FieldsComponent < ApplicationComponent
if !attachable.persisted? && attachable.cached_attachment.present?
link_to t("#{plural_name}.form.delete_button"), "#", class: "delete remove-cached-attachment"
else
link_to_remove_association attachable.new_record? ? t("documents.form.cancel_button") : t("#{plural_name}.form.delete_button"), f, class: "delete remove-#{singular_name}"
link_to_remove_association remove_association_text, f, class: "delete remove-#{singular_name}"
end
end
def remove_association_text
if attachable.new_record?
t("documents.form.cancel_button")
else
t("#{plural_name}.form.delete_button")
end
end