更改 ActiveStorage 控制器路径 [英] Change the ActiveStorage Controller Path
本文介绍了更改 ActiveStorage 控制器路径的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
有没有办法自定义附件网址而不是
Is there a way to customize the attachment urls so instead of
/rails/active_storage/representations/
/rails/active_storage/blobs/
我们可以有这样的东西:
We could have something like this:
/custom_path/representations/
/custom_path/blobs/
推荐答案
最近添加了一个可以配置路由前缀的内容:https://github.com/rails/rails/commit/7dd9916c0d5e5d149bdde8cbeec42ca49cf3f6ca
Recently, there was an addition which makes the route prefix configurable: https://github.com/rails/rails/commit/7dd9916c0d5e5d149bdde8cbeec42ca49cf3f6ca
现在只是在master分支,但应该集成到~> 5.2.2已经集成到Rails 6.0.0及更高版本.
Just in master branch now, but should be integrated into ~> 5.2.2 have been integrated into Rails 6.0.0 and higher.
那么,这只是一个配置问题:
Then, it's just a matter of configuration:
Rails.application.configure do
config.active_storage.routes_prefix = '/whereever'
end
这篇关于更改 ActiveStorage 控制器路径的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文