Sha256: 50ba8bbc86021489164612c98372f796d3caa1778d763bfb5b8991450bce03cc

Contents?: true

Size: 656 Bytes

Versions: 7

Compression:

Stored size: 656 Bytes

Contents

module Para
  module Library
    class File < ActiveRecord::Base
      has_attached_file :attachment

      validates :attachment, presence: true
      do_not_validate_attachment_file_type :attachment

      # Return attachment.path or attachment.url depending on the storage
      # backend, allowing 'openuri' and 'roo' libraries to load easily the
      # file at the right path, on filesystem or othe storage systems, like S3.
      #
      def attachment_path
        return unless attachment?

        case attachment.options[:storage]
        when :filesystem then attachment.path
        else attachment.url
        end
      end
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
para-0.7.1 app/models/para/library/file.rb
para-0.7.0 app/models/para/library/file.rb
para-0.6.9 app/models/para/library/file.rb
para-0.6.8 app/models/para/library/file.rb
para-0.6.7 app/models/para/library/file.rb
para-0.6.3 app/models/para/library/file.rb
para-0.6.2 app/models/para/library/file.rb