Module: Shrine::Plugins::KitheStorageLocation::InstanceMethods

Defined in:
lib/shrine/plugins/kithe_storage_location.rb

Instance Method Summary collapse

Instance Method Details

#generate_location(io, context) ⇒ Object



15
16
17
18
19
20
21
22
23
# File 'lib/shrine/plugins/kithe_storage_location.rb', line 15

def generate_location(io, context)
  # If it doesn't have a id, we're probably storing in cache, possibly as part
  # of direct upload endpoint. A better path will be created on store.
  id = context[:record].id if context[:record].respond_to?(:id)

  basename = super

  ["asset", id, basename].compact.join("/")
end