From 1a9026b485b9b1da0f34c526d4c901406074c508 Mon Sep 17 00:00:00 2001 From: David Heinemeier Hansson Date: Thu, 20 Jul 2017 17:33:31 -0500 Subject: Extract routes.rb to engine location for auto configuration --- config/routes.rb | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 config/routes.rb (limited to 'config') diff --git a/config/routes.rb b/config/routes.rb new file mode 100644 index 0000000000..9057eadc8a --- /dev/null +++ b/config/routes.rb @@ -0,0 +1,13 @@ +Rails.application.routes.draw do + get "/rails/active_storage/disk/:encoded_key/*filename" => "active_storage/disk#show", as: :rails_disk_blob + get "/rails/active_storage/variants/:encoded_blob_key/:encoded_variant_key/*filename" => "active_storage/variants#show", as: :rails_blob_variant + post "/rails/active_storage/direct_uploads" => "active_storage/direct_uploads#create", as: :rails_direct_uploads + + resolve 'ActiveStorage::Variant' do |variant| + encoded_blob_key = ActiveStorage::VerifiedKeyWithExpiration.encode(variant.blob.key) + encoded_variant_key = ActiveStorage::Variant.encode_key(variant.variation) + filename = variant.blob.filename + + route_for(:rails_blob_variant, encoded_blob_key, encoded_variant_key, filename) + end +end -- cgit v1.2.3