Rails ActiveStorage: how to avoid one redirect for each image?

前端 未结 2 932
梦毁少年i
梦毁少年i 2021-02-06 13:38

If you use ActiveStorage and you have a page with N images you get N additional requests to your Rails app (i.e. N redirects). That means wasting a lot of server resources if yo

2条回答
  •  萌比男神i
    2021-02-06 14:43

    You can use the service_url to create direct links to your resources.

    We don't use Rails views in our project so my knowledge about the view layer is rusty. I think you could put it in a dedicated helper and then use it from your views.

提交回复
热议问题