Module: PaperclipI18n::ActsAsAttachment::ClassMethods

Defined in:
lib/paperclip_i18n/acts_as_attachment.rb

Instance Method Summary collapse

Instance Method Details

#acts_as_attachment(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/acts_as_attachment.rb', line 12

def acts_as_attachment(options = {})
  default_options = options
  default_options[:url] = "/uploads/#{Rails.env}/assets/:id_partition/:basename.:style.:extension" if default_options[:url].blank?
  default_options[:path] = "#{Rails.root}/public/uploads/#{Rails.env}/assets/:id_partition/:basename.:style.:extension" if default_options[:path].blank?

  has_attached_file(:upload, default_options)
  belongs_to(:attachable, :polymorphic => true)
  scope(:i18ns, lambda { where(:upload_language => ::I18n.locale.to_s) })
  include(::PaperclipI18n::ActsAsAttachment::InstanceMethods)
end