aboutsummaryrefslogtreecommitdiffstats
path: root/activestorage/lib
diff options
context:
space:
mode:
authorChris Bisnett <cbisnett@gmail.com>2018-09-14 10:23:32 -0400
committerChris Bisnett <cbisnett@gmail.com>2018-09-14 10:40:18 -0400
commit7dd9916c0d5e5d149bdde8cbeec42ca49cf3f6ca (patch)
tree75a4fd691ac8d1cdb1d67a1cd469c26bb837c4e6 /activestorage/lib
parentd3c73ae5e4ebabdf6c79e490fddb2cbfb0de3b76 (diff)
downloadrails-7dd9916c0d5e5d149bdde8cbeec42ca49cf3f6ca.tar.gz
rails-7dd9916c0d5e5d149bdde8cbeec42ca49cf3f6ca.tar.bz2
rails-7dd9916c0d5e5d149bdde8cbeec42ca49cf3f6ca.zip
Configure Active Storage route prefix
Applications can configure the route prefix prepended to the Active Storage routes. By default this maintains the previous prefix `/rails/active_storage` but supports custom prefixes. Before this change the route for serving blobs is fixed to `/rails/active_storage/blobs/:signed_id/*filename`. After this change it's possible to configure the route to something like `/files/blobs/:signed_id/*filename`.
Diffstat (limited to 'activestorage/lib')
-rw-r--r--activestorage/lib/active_storage.rb1
-rw-r--r--activestorage/lib/active_storage/engine.rb1
2 files changed, 2 insertions, 0 deletions
diff --git a/activestorage/lib/active_storage.rb b/activestorage/lib/active_storage.rb
index d3e3a2f49b..a94ef626f2 100644
--- a/activestorage/lib/active_storage.rb
+++ b/activestorage/lib/active_storage.rb
@@ -50,6 +50,7 @@ module ActiveStorage
mattr_accessor :variable_content_types, default: []
mattr_accessor :content_types_to_serve_as_binary, default: []
mattr_accessor :service_urls_expire_in, default: 5.minutes
+ mattr_accessor :routes_prefix, default: "/rails/active_storage"
module Transformers
extend ActiveSupport::Autoload
diff --git a/activestorage/lib/active_storage/engine.rb b/activestorage/lib/active_storage/engine.rb
index 9d6a27eabe..7eb93b5e16 100644
--- a/activestorage/lib/active_storage/engine.rb
+++ b/activestorage/lib/active_storage/engine.rb
@@ -51,6 +51,7 @@ module ActiveStorage
ActiveStorage.previewers = app.config.active_storage.previewers || []
ActiveStorage.analyzers = app.config.active_storage.analyzers || []
ActiveStorage.paths = app.config.active_storage.paths || {}
+ ActiveStorage.routes_prefix = app.config.active_storage.routes_prefix || "/rails/active_storage"
ActiveStorage.variable_content_types = app.config.active_storage.variable_content_types || []
ActiveStorage.content_types_to_serve_as_binary = app.config.active_storage.content_types_to_serve_as_binary || []