From 1f161bee1f36ab957aeaa631b748125584ff69dd Mon Sep 17 00:00:00 2001 From: AthiraKadampatta Date: Tue, 4 Oct 2022 00:01:39 +0530 Subject: [PATCH 1/4] Add paperclip columns to ignored columns list for enterprise, enterprise group, terms_of_service_file, spree/image models --- app/models/enterprise.rb | 13 +++++++++++++ app/models/enterprise_group.rb | 9 +++++++++ app/models/spree/image.rb | 5 +++++ app/models/terms_of_service_file.rb | 5 +++++ 4 files changed, 32 insertions(+) diff --git a/app/models/enterprise.rb b/app/models/enterprise.rb index 8d62a1cc94..f25d5f7f1b 100644 --- a/app/models/enterprise.rb +++ b/app/models/enterprise.rb @@ -16,6 +16,19 @@ class Enterprise < ApplicationRecord large: { resize_to_fill: [1200, 260] }, }.freeze + self.ignored_columns = %i(terms_and_conditions_file_name + terms_and_conditions_content_type + terms_and_conditions_file_size + terms_and_conditions_updated_at + logo_file_name + logo_content_type + logo_file_size + logo_updated_at + promo_image_file_name + promo_image_content_type + promo_image_file_size + promo_image_updated_at) + searchable_attributes :sells, :is_primary_producer searchable_associations :properties searchable_scopes :is_primary_producer, :is_distributor, :is_hub, :activated, :visible, diff --git a/app/models/enterprise_group.rb b/app/models/enterprise_group.rb index a791405965..2ba7466710 100644 --- a/app/models/enterprise_group.rb +++ b/app/models/enterprise_group.rb @@ -5,6 +5,15 @@ require 'open_food_network/locking' class EnterpriseGroup < ApplicationRecord include PermalinkGenerator + self.ignored_columns = %i(logo_file_name + logo_content_type + logo_file_size + logo_updated_at + promo_image_file_name + promo_image_content_type + promo_image_file_size + promo_image_updated_at) + acts_as_list has_and_belongs_to_many :enterprises, join_table: 'enterprise_groups_enterprises' diff --git a/app/models/spree/image.rb b/app/models/spree/image.rb index 4c28ed121a..05f7f1ea32 100644 --- a/app/models/spree/image.rb +++ b/app/models/spree/image.rb @@ -9,6 +9,11 @@ module Spree large: { resize_to_limit: [600, 600] }, }.freeze + self.ignored_columns = %i(attachment_file_name + attachment_content_type + attachment_file_size + attachment_updated_at) + has_one_attached :attachment validates :attachment, attached: true, content_type: %r{\Aimage/(png|jpeg|gif|jpg|svg\+xml|webp)\Z} diff --git a/app/models/terms_of_service_file.rb b/app/models/terms_of_service_file.rb index 2fb35aab3c..e2b6c0b87e 100644 --- a/app/models/terms_of_service_file.rb +++ b/app/models/terms_of_service_file.rb @@ -5,6 +5,11 @@ class TermsOfServiceFile < ApplicationRecord validates :attachment, attached: true + self.ignored_columns = %i(attachment_file_name + attachment_content_type + attachment_file_size + attachment_updated_at) + # The most recently uploaded file is the current one. def self.current order(:id).last From f40b569a4a7d9c3a28baba3ed3a31e0a4032203e Mon Sep 17 00:00:00 2001 From: AthiraKadampatta Date: Fri, 7 Oct 2022 11:08:52 +0530 Subject: [PATCH 2/4] 9726 Use active storage filename instead of attachment_file_name of paperclip --- app/views/spree/admin/images/edit.html.haml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/spree/admin/images/edit.html.haml b/app/views/spree/admin/images/edit.html.haml index 970f67d132..6c6c035827 100644 --- a/app/views/spree/admin/images/edit.html.haml +++ b/app/views/spree/admin/images/edit.html.haml @@ -7,7 +7,7 @@ = form_for [:admin, @product, @image], url: admin_product_image_path(@product, @image, @url_filters), html: { multipart: true } do |f| %fieldset - %legend{align: "center"}= @image.attachment_file_name + %legend{align: "center"}= @image.attachment&.filename .field.alpha.three.columns.align-center = f.label t('spree.thumbnail') %br/ From 80eef9c30200204fa1fd47ac34857e1e755ef45c Mon Sep 17 00:00:00 2001 From: AthiraKadampatta Date: Fri, 7 Oct 2022 11:10:21 +0530 Subject: [PATCH 3/4] 9726 Add attachment_width and attachment_height to the list of ignored columns for spree images --- app/models/spree/image.rb | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/app/models/spree/image.rb b/app/models/spree/image.rb index 05f7f1ea32..c65b5b46ba 100644 --- a/app/models/spree/image.rb +++ b/app/models/spree/image.rb @@ -12,7 +12,9 @@ module Spree self.ignored_columns = %i(attachment_file_name attachment_content_type attachment_file_size - attachment_updated_at) + attachment_updated_at + attachment_width + attachment_height) has_one_attached :attachment From b2c778794d679e9cfb15cce7a2c6cf0dbe7e4543 Mon Sep 17 00:00:00 2001 From: AthiraKadampatta Date: Mon, 10 Oct 2022 11:09:48 +0530 Subject: [PATCH 4/4] 9726 Remove safe navigation operator and simplify call to attachment file name --- app/views/spree/admin/images/edit.html.haml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/spree/admin/images/edit.html.haml b/app/views/spree/admin/images/edit.html.haml index 6c6c035827..711dd32fbb 100644 --- a/app/views/spree/admin/images/edit.html.haml +++ b/app/views/spree/admin/images/edit.html.haml @@ -7,7 +7,7 @@ = form_for [:admin, @product, @image], url: admin_product_image_path(@product, @image, @url_filters), html: { multipart: true } do |f| %fieldset - %legend{align: "center"}= @image.attachment&.filename + %legend{align: "center"}= @image.attachment.filename .field.alpha.three.columns.align-center = f.label t('spree.thumbnail') %br/