Module: PaperclipI18n::HasManyAttachedFiles::ClassMethods

Defined in:
lib/paperclip_i18n/has_many_attached_files.rb

Instance Method Summary collapse

Instance Method Details

#has_many_attached_files(options = {}) ⇒ Object

Extends the model to afford the ability to associate other records with the receiving record.

This module needs the paperclip plugin to work www.thoughtbot.com/projects/paperclip



12
13
14
15
16
17
18
19
20
21
# File 'lib/paperclip_i18n/has_many_attached_files.rb', line 12

def has_many_attached_files(options = {})
  class_attribute(:has_many_attached_files_options)
  self.has_many_attached_files_options = { :counter_cache => options[:counter_cache], :styles => options[:styles], :model => options[:model] ||= ::Asset }
  
  attr_accessor(:upload)
  attr_accessor(:current_file_language)
  after_save(:save_attached_files)
  has_many(:assets, :as => :attachable, :dependent => :destroy, :class_name => self.has_many_attached_files_options[:model].to_s)
  include(::PaperclipI18n::HasManyAttachedFiles::InstanceMethods)
end