26 lines
		
	
	
		
			526 B
		
	
	
	
		
			Ruby
		
	
	
	
			
		
		
	
	
			26 lines
		
	
	
		
			526 B
		
	
	
	
		
			Ruby
		
	
	
	
class Asset
 | 
						|
 | 
						|
  include Mongoid::Document
 | 
						|
  include Mongoid::Timestamps
 | 
						|
 | 
						|
  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
 | 
						|
  has_and_belongs_to_many :tags, :class_name => "AssetTag"
 | 
						|
 | 
						|
  def sorted_tags
 | 
						|
    tags.order_by(I18n.locale, :asc)
 | 
						|
  end
 | 
						|
  
 | 
						|
end
 |