要獲得控制器我用下面的方法圖像路徑:Rails 3:如何在控制器中獲取圖像路徑?
class AssetsController < ApplicationController
def download(image_file_name)
path = Rails.root.join("public", "images", image_file_name).to_s
send_file(path, ...)
end
end
是否有更好的方法來尋找路徑?
這對我不起作用,我想用'image_path'而不是'asset_path'。它無法定位我的圖像文件夾中的文件。改爲使用'view_context'。 –