Module: CarrierWave::Uploader::Url

Extended by:
ActiveSupport::Concern
Includes:
Configuration
Included in:
Base
Defined in:
lib/carrierwave/uploader/url.rb

Instance Method Summary collapse

Instance Method Details

#as_json(options = nil) ⇒ Object

Returns

Hash

the locations where this file and versions are accessible via a url



29
30
31
32
# File 'lib/carrierwave/uploader/url.rb', line 29

def as_json(options = nil)
  h = { :url => url }
  h.merge Hash[versions.map { |name, version| [name, { :url => version.url }] }]
end

#to_xml(options = nil) ⇒ Object

FIXME to_xml should work like to_json, but this is the best we’ve been able to do so far. This hack fixes issue #337.

Returns

nil


42
43
# File 'lib/carrierwave/uploader/url.rb', line 42

def to_xml(options = nil)
end

#urlObject Also known as: to_s

Returns

String

the location where this file is accessible via a url



14
15
16
17
18
19
20
# File 'lib/carrierwave/uploader/url.rb', line 14

def url
  if file.respond_to?(:url) and not file.url.blank?
    file.url
  elsif current_path
    (base_path || "") + File.expand_path(current_path).gsub(File.expand_path(root), '')
  end
end