Orbit/app/models/asset.rb

30 lines
529 B
Ruby

class Asset
include Mongoid::Document
include Mongoid::Timestamps
include OrbitTag::Taggable
mount_uploader :data, FileAssetUploader
field :filename
field :description, localize: true
field :title, localize: true
validates :title, :at_least_one => true
validates :description, :at_least_one => true
validates_presence_of :data
belongs_to :asset_category
belongs_to :assetable, polymorphic: true
before_save :clean_tags
protected
def clean_tags
self.tagged_ids.delete('')
end
end