Module: Sunrise::FileUpload::ActiveRecord::SingletonMethods

Defined in:
lib/sunrise/file_upload/active_record.rb

Instance Method Summary collapse

Instance Method Details

#fileuploads(*args) ⇒ Object



9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/sunrise/file_upload/active_record.rb', line 9

def fileuploads(*args)
  options = args.extract_options!
  
  class_attribute :fileuploads_options, :instance_writer => false
  self.fileuploads_options = options
  
  class_attribute :fileuploads_columns, :instance_writer => false
  self.fileuploads_columns = args.map(&:to_sym)
  
  unless self.is_a?(ClassMethods)
    include InstanceMethods
    extend ClassMethods
    
    attr_accessible :fileupload_guid
    after_save :fileuploads_update, :if => :fileupload_changed?
    
    args.each do |asset|
      accepts_nested_attributes_for asset, :allow_destroy => true
    end
  end
end