Sha256: bba1899fa89ea7402877030520f53dc5daae3c37fd93b501cd69cc5bf4a29b42
Contents?: true
Size: 1.37 KB
Versions: 1
Compression:
Stored size: 1.37 KB
Contents
require 'paperclip' module Transit module Model module Attachments extend ActiveSupport::Concern included do include Paperclip::Glue end #Convenience method for only finding the assets that are images def images self.assets.find_all{ |asset| asset.image? } end def image? image.file? end # Convenience method for only finding the assets that are files def files self.assets.reject{ |asset| asset.image? } end # Override to show a "default image" in the admin. def preview_image_url nil end module ClassMethods ## # Convenience method for Paperclip's has_attached_file to ensure fields also exist. # 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 end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
transit-0.0.2 | lib/transit/model/attachments.rb |