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 attachement URL of the custom asset
|
|
|
|
def self.get_url(name)
|
|
|
|
asset = CustomAsset.find_by(name: name)
|
|
|
|
asset.custom_asset_file.attachment_url if asset and asset.custom_asset_file
|
|
|
|
end
|
2016-05-18 16:15:54 +02:00
|
|
|
|
|
|
|
after_update :update_stylesheet if :viewable_changed?
|
|
|
|
|
|
|
|
def update_stylesheet
|
|
|
|
if %w(profile-image-file).include? self.name
|
|
|
|
Stylesheet.first.rebuild!
|
|
|
|
end
|
|
|
|
end
|
2016-03-23 18:39:41 +01:00
|
|
|
end
|