1
0
mirror of https://github.com/LaCasemate/fab-manager.git synced 2024-12-11 22:24:21 +01:00
fab-manager/app/models/custom_asset.rb

17 lines
528 B
Ruby
Raw Normal View History

2016-03-23 18:39:41 +01:00
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
2016-03-23 18:39:41 +01:00
def self.get_url(name)
asset = CustomAsset.find_by(name: name)
asset&.custom_asset_file&.attachment_url
2016-03-23 18:39:41 +01:00
end
after_update :update_stylesheet if :viewable_changed?
def update_stylesheet
Stylesheet.first.rebuild! if %w[profile-image-file].include? name
end
2016-03-23 18:39:41 +01:00
end