Sha256: ab95ebc7a3c423fa220efb6e13e18bde902f97662a26a9e1a7b6d8ef79dc3097
Contents?: true
Size: 995 Bytes
Versions: 1
Compression:
Stored size: 995 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 } } } } 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 def self.options_for(target = class_name) (Setting.current.attachments[target] || {}).symbolize_keys end define_index do indexes filename, :sortable => true indexes content_type, :sortable => true indexes size, :sortable => true end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
forgeos_core-1.9.5.rc1 | app/models/attachment.rb |