Sha256: 40761e0620b80e4733b1d1257aa3af0b1e1f838d92e014239a65e11abc764fe5

Contents?: true

Size: 1.28 KB

Versions: 27

Compression:

Stored size: 1.28 KB

Contents

module Apidae
  class AttachedFile < ActiveRecord::Base
    belongs_to :apidae_object, :class_name => 'Apidae::Object'

    has_attached_file :picture,
                      {
                          :styles => {
                              :xlarge => ['1600x1200>', :jpg],
                              :large => ['1280x960>', :jpg],
                              :medium => ['800x600>', :jpg],
                              :small => ['320x240', :jpg],
                              :thumb => ['200x200>', :png]
                          },
                          :default_url => "/#{Rails.application.config.apidae_pictures_path}/default/logo.png",
                          :path => "public/#{Rails.application.config.apidae_pictures_path}/:apidae_type/:apidae_id/:basename.:extension",
                          :url => "/#{Rails.application.config.apidae_pictures_path}/:apidae_type/:apidae_id/:basename.:extension"
                      }

    validates_attachment :picture, content_type: { content_type: /\Aimage\/.*\Z/ }

    private

    Paperclip.interpolates :apidae_type do |attachment, style|
      attachment.instance.apidae_object.apidae_type.downcase
    end

    Paperclip.interpolates :apidae_id do |attachment, style|
      attachment.instance.apidae_object.apidae_id
    end
  end
end

Version data entries

27 entries across 27 versions & 2 rubygems

Version Path
apidae-0.2.0 app/models/apidae/attached_file.rb
apidae-0.1.4 app/models/apidae/attached_file.rb
apidae-0.1.3 app/models/apidae/attached_file.rb
apidae-0.1.2 app/models/apidae/attached_file.rb
apidae-0.1.1 app/models/apidae/attached_file.rb
apidae-0.1.0 app/models/apidae/attached_file.rb
apidae-engine-rails-0.1.0 app/models/apidae/attached_file.rb