mirror of
https://github.com/LaCasemate/fab-manager.git
synced 2024-12-01 12:24:28 +01:00
20 lines
620 B
Ruby
20 lines
620 B
Ruby
# frozen_string_literal: true
|
|
|
|
# Admin defined assets (like PDF or images uploaded)
|
|
class CustomAsset < ActiveRecord::Base
|
|
has_one :custom_asset_file, as: :viewable, dependent: :destroy
|
|
accepts_nested_attributes_for :custom_asset_file, allow_destroy: true
|
|
|
|
# static method to retrieve the attachment URL of the custom asset
|
|
def self.get_url(name)
|
|
asset = CustomAsset.find_by(name: name)
|
|
asset&.custom_asset_file&.attachment_url
|
|
end
|
|
|
|
after_update :update_stylesheet if :saved_change_to_viewable?
|
|
|
|
def update_stylesheet
|
|
Stylesheet.theme.rebuild! if %w[profile-image-file].include? name
|
|
end
|
|
end
|