Sha256: 778fdf0ec778da4b3ecc3856a798ccf224260c7a08040937bc4e3530fd73303c

Contents?: true

Size: 662 Bytes

Versions: 16

Compression:

Stored size: 662 Bytes

Contents

module Adminsite
  class FileAsset < ActiveRecord::Base

    has_attached_file :attachment

    validates_with AttachmentPresenceValidator, :attributes => :attachment
    validates_with AttachmentSizeValidator, :attributes => :attachment, :less_than => 2.megabytes
    validates_attachment :attachment, content_type: { content_type: /\A.*\Z/ }
    # do_not_validate_attachment_file_type :image

    class << self
      def attachment_url_for(name)
        asset = find_by_attachment_file_name(name)
        if asset.nil?
          "http://missing.jpg?#{name}"
        else
          asset.attachment.url(:original, false)
        end
      end
    end
  end
end

Version data entries

16 entries across 16 versions & 1 rubygems

Version Path
adminsite-3.2.4 app/models/adminsite/file_asset.rb
adminsite-3.2.3 app/models/adminsite/file_asset.rb
adminsite-3.2.2 app/models/adminsite/file_asset.rb
adminsite-3.2.1 app/models/adminsite/file_asset.rb
adminsite-3.2.0 app/models/adminsite/file_asset.rb
adminsite-3.1.2 app/models/adminsite/file_asset.rb
adminsite-3.1.1 app/models/adminsite/file_asset.rb
adminsite-3.1.0 app/models/adminsite/file_asset.rb
adminsite-3.0.0 app/models/adminsite/file_asset.rb
adminsite-2.1.2 app/models/adminsite/file_asset.rb
adminsite-2.1.1 app/models/adminsite/file_asset.rb
adminsite-2.1.0 app/models/adminsite/file_asset.rb
adminsite-2.0.3 app/models/adminsite/file_asset.rb
adminsite-2.0.2 app/models/adminsite/file_asset.rb
adminsite-2.0.1 app/models/adminsite/file_asset.rb
adminsite-2.0.0 app/models/adminsite/file_asset.rb