要获取控制器中的图像路径,我使用以下方法:
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')
从 Rails 控制器访问资产路径 https://stackoverflow.com/questions/7827078/access-asset-path-from-rails-controller
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)