Sha256: b5b0787476ed806b2b7251db2baa15982abe7001a1763cbbddf521e628bdb441
Contents?: true
Size: 1002 Bytes
Versions: 4
Compression:
Stored size: 1002 Bytes
Contents
class Attachment < ActiveRecord::Base has_and_belongs_to_many :categories, :readonly => true, :join_table => 'categories_elements', :foreign_key => 'element_id', :association_foreign_key => 'category_id' has_many :attachment_links, :dependent => :destroy before_save :fill_blank_name_with_filename scope :linked_to, lambda { |element_type| { :include => :attachment_links, :conditions => { :attachment_links => { :element_type => element_type.to_s.classify } } } } define_index do indexes filename, :sortable => true indexes content_type, :sortable => true indexes size, :sortable => true end def file_type content_type.split('/').last end def fill_blank_name_with_filename if name.blank? and filename self.name = filename.split('.').first end end private def self.options_for(target = class_name) (Setting.current.attachments[target] || {}).symbolize_keys end end
Version data entries
4 entries across 4 versions & 1 rubygems
Version | Path |
---|---|
forgeos_core-1.9.4 | app/models/attachment.rb |
forgeos_core-1.9.3 | app/models/attachment.rb |
forgeos_core-1.9.2 | app/models/attachment.rb |
forgeos_core-1.9.1 | app/models/attachment.rb |