5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
|
# File 'app/models/alchemy/storage_adapter/active_storage.rb', line 5
def self.included(base)
base.has_one_attached :image_file do |attachable|
Alchemy.storage_adapter.preprocessor_class.new(attachable).call
Alchemy.storage_adapter.preprocessor_class.generate_thumbs!(attachable)
end
base.after_create_commit if: :svg? do
SanitizeSvgJob.perform_later(self, file_accessor: :image_file)
end
base.before_update do
@image_file_replaced = image_file.changed?
end
base.after_update_commit if: -> { @image_file_replaced && svg? } do
SanitizeSvgJob.perform_later(self, file_accessor: :image_file)
end
end
|