aboutsummaryrefslogtreecommitdiffstats
path: root/config
diff options
context:
space:
mode:
authorDavid Heinemeier Hansson <david@loudthinking.com>2017-07-21 16:51:04 -0500
committerGitHub <noreply@github.com>2017-07-21 16:51:04 -0500
commitf0d7ce9e767ffbf7307ed6efaa4a189ae3ea3c0a (patch)
tree545ce85fc61a1e6bcc75110428648dbf9d59a0ac /config
parent986a71d26868d296f4c619df85909d1073b6c91f (diff)
parent6ac4fec964e67cf3d7dfbf7726bff9b05aca522c (diff)
downloadrails-f0d7ce9e767ffbf7307ed6efaa4a189ae3ea3c0a.tar.gz
rails-f0d7ce9e767ffbf7307ed6efaa4a189ae3ea3c0a.tar.bz2
rails-f0d7ce9e767ffbf7307ed6efaa4a189ae3ea3c0a.zip
Merge pull request #63 from rails/variants
On-demand variants
Diffstat (limited to 'config')
-rw-r--r--config/routes.rb16
1 files changed, 16 insertions, 0 deletions
diff --git a/config/routes.rb b/config/routes.rb
new file mode 100644
index 0000000000..d25f2c82f0
--- /dev/null
+++ b/config/routes.rb
@@ -0,0 +1,16 @@
+Rails.application.routes.draw do
+ get "/rails/active_storage/disk/:encoded_key/*filename" => "active_storage/disk#show", as: :rails_disk_blob
+ post "/rails/active_storage/direct_uploads" => "active_storage/direct_uploads#create", as: :rails_direct_uploads
+
+ get "/rails/active_storage/variants/:encoded_blob_key/:variation_key/*filename" => "active_storage/variants#show", as: :rails_blob_variation
+
+ direct :rails_variant do |variant|
+ encoded_blob_key = ActiveStorage::VerifiedKeyWithExpiration.encode(variant.blob.key)
+ variation_key = variant.variation.key
+ filename = variant.blob.filename
+
+ route_for(:rails_blob_variation, encoded_blob_key, variation_key, filename)
+ end
+
+ resolve('ActiveStorage::Variant') { |variant| route_for(:rails_variant, variant) }
+end