diff --git a/app/models/comfy/cms/file.rb b/app/models/comfy/cms/file.rb index e8bb3a673..19b05ce45 100644 --- a/app/models/comfy/cms/file.rb +++ b/app/models/comfy/cms/file.rb @@ -23,7 +23,12 @@ class Comfy::Cms::File < ActiveRecord::Base # -- Callbacks --------------------------------------------------------------- before_validation :assign_label, on: :create before_create :assign_position - after_save :process_attachment + # active_storage attachment behavior changed in rails 6 - see PR#892 for details + if Rails::VERSION::MAJOR >= 6 + before_save :process_attachment + else + after_save :process_attachment + end # -- Validations ------------------------------------------------------------- validates :label, presence: true diff --git a/app/models/comfy/cms/fragment.rb b/app/models/comfy/cms/fragment.rb index 3d4d034dc..5115b6704 100644 --- a/app/models/comfy/cms/fragment.rb +++ b/app/models/comfy/cms/fragment.rb @@ -11,8 +11,12 @@ class Comfy::Cms::Fragment < ActiveRecord::Base attr_reader :files # -- Callbacks --------------------------------------------------------------- - after_save :remove_attachments, - :add_attachments + # active_storage attachment behavior changed in rails 6 - see PR#892 for details + if Rails::VERSION::MAJOR >= 6 + before_save :remove_attachments, :add_attachments + else + after_save :remove_attachments, :add_attachments + end # -- Relationships ----------------------------------------------------------- belongs_to :record, polymorphic: true, touch: true