Sha256: 01621185f4d41fcb052ec55a64e804e59639a3f03ea8295671559edc575f5952

Contents?: true

Size: 1.2 KB

Versions: 39

Compression:

Stored size: 1.2 KB

Contents

class Lalala::Uploaders::File < CarrierWave::Uploader::Base

  def store_dir
    if Rails.env.production? or Rails.env.staging?
      "#{model.class.to_s.underscore}/#{model.id}"
    else
      "uploads/#{model.class.to_s.underscore}/#{model.id}"
    end
  end

  def url(*)
    super_url = super
    if Rails.env.production? or Rails.env.staging?
      if super_url
        AssetURL.new(File.join("/storage/assets", super_url))
      else
        super_url
      end
    else
      super_url
    end
  end

  # This class circumvents the Sprockets asset path rewriting
  # by pretending that it is a full URL.
  #
  # @see
  #   https://mrhenry.basecamphq.com/projects/10235776-hetpaleis/todo_items/164031435/comments (internal)
  #   http://apidock.com/rails/ActionView/Helpers/AssetTagHelper/image_tag
  #   http://apidock.com/rails/v3.2.13/ActionView/Helpers/AssetTagHelper/path_to_image
  #   http://apidock.com/rails/ActionView/Helpers/AssetTagHelper/image_path
  #   http://apidock.com/rails/ActionView/AssetPaths/compute_public_path
  #   http://apidock.com/rails/v3.2.13/ActionView/AssetPaths/is_uri%3F
  class AssetURL < String

    def to_s
      self
    end

    def =~(pattern)
      return true
    end

  end

end

Version data entries

39 entries across 39 versions & 1 rubygems

Version Path
lalala-4.0.0.dev.194 lib/lalala/uploaders/file.rb
lalala-4.0.0.dev.193 lib/lalala/uploaders/file.rb
lalala-4.0.0.dev.192 lib/lalala/uploaders/file.rb
lalala-4.0.0.dev.191 lib/lalala/uploaders/file.rb
lalala-4.0.0.dev.190 lib/lalala/uploaders/file.rb
lalala-4.0.0.dev.189 lib/lalala/uploaders/file.rb
lalala-4.0.0.dev.188 lib/lalala/uploaders/file.rb
lalala-4.0.0.dev.187 lib/lalala/uploaders/file.rb
lalala-4.0.0.dev.186 lib/lalala/uploaders/file.rb
lalala-4.0.0.dev.185 lib/lalala/uploaders/file.rb
lalala-4.0.0.dev.184 lib/lalala/uploaders/file.rb
lalala-4.0.0.dev.183 lib/lalala/uploaders/file.rb
lalala-4.0.0.dev.181 lib/lalala/uploaders/file.rb
lalala-4.0.0.dev.180 lib/lalala/uploaders/file.rb
lalala-4.0.0.dev.179 lib/lalala/uploaders/file.rb
lalala-4.0.0.dev.178 lib/lalala/uploaders/file.rb
lalala-4.0.0.dev.177 lib/lalala/uploaders/file.rb
lalala-4.0.0.dev.176 lib/lalala/uploaders/file.rb
lalala-4.0.0.dev.170 lib/lalala/uploaders/file.rb
lalala-4.0.0.dev.168 lib/lalala/uploaders/file.rb