Module: Transit::Model::Attachments::ClassMethods

Defined in:
lib/transit/model/attachments.rb

Instance Method Summary collapse

Instance Method Details

#attach(name, options = {}) ⇒ Object

Convenience method for Paperclip’s has_attached_file to ensure fields also exist.



35
36
37
38
39
40
41
42
43
44
45
46
47
48
# File 'lib/transit/model/attachments.rb', line 35

def attach(name, options = {})
  
  if options[:styles].present?
    options.reverse_merge!(original: '1500x1500>')
  end
  
  has_attached_file name, options
  field :"#{name.to_s}_file_name",     :type => String
  field :"#{name.to_s}_content_type",  :type => String
  field :"#{name.to_s}_file_size",     :type => Integer
  field :"#{name.to_s}_updated_at",    :type => Time
  field :"#{name.to_s}_fingerprint",   :type => String
  
end