From 5468f82ed98534caba9e3a60d3e94d8555ea68cd Mon Sep 17 00:00:00 2001 From: Jon Frisby Date: Tue, 30 Jan 2024 01:45:19 -0800 Subject: [PATCH] Make default of `:attachments_disabled` context-aware. (#2429) --- lib/avo/fields/trix_field.rb | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/lib/avo/fields/trix_field.rb b/lib/avo/fields/trix_field.rb index f9c109ce35..601fb833fc 100644 --- a/lib/avo/fields/trix_field.rb +++ b/lib/avo/fields/trix_field.rb @@ -14,8 +14,11 @@ def initialize(id, **args, &block) hide_on :index @always_show = args[:always_show] || false - @attachments_disabled = args[:attachments_disabled] || false @attachment_key = args[:attachment_key] + # If we don't have an attachment_key, we disable attachments. There's no point in having + # attachments if we can't store them. + @attachments_disabled = args[:attachments_disabled] || true + @attachments_disabled = false unless @attachment_key.present? @hide_attachment_filename = args[:hide_attachment_filename] || false @hide_attachment_filesize = args[:hide_attachment_filesize] || false @hide_attachment_url = args[:hide_attachment_url] || false