gpt4 book ai didi

ruby-on-rails - rails 3 : How to get image path in Controller?

转载 作者:行者123 更新时间:2023-12-03 10:31:05 25 4
gpt4 key购买 nike

要在 Controller 中获取图像路径,我使用以下方法:

class AssetsController < ApplicationController
def download(image_file_name)
path = Rails.root.join("public", "images", image_file_name).to_s
send_file(path, ...)
end
end

有没有更好的方法来找到路径?

最佳答案

ActionController::Base.helpers.asset_path('missing_file.jpg')

Access Asset Path from Rails Controller

关于ruby-on-rails - rails 3 : How to get image path in Controller?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6519141/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com