Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/ruby-on-rails/55.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ruby on rails 图像未显示,尽管已硬编码-Rails_Ruby On Rails_Ruby On Rails 4.1 - Fatal编程技术网

Ruby on rails 图像未显示,尽管已硬编码-Rails

Ruby on rails 图像未显示,尽管已硬编码-Rails,ruby-on-rails,ruby-on-rails-4.1,Ruby On Rails,Ruby On Rails 4.1,我认为: Rails 4.1 Ruby 2.1.1 但是当我检查时,文件/home/dnc/app/assets/images/cw/agent/avatar/11/thumb_myimage.jpg确实存在。有什么想法吗 路径帮助程序 有人会问,为什么不使用来访问图像目录: INFO -- : Started GET "/home/dnc/app/assets/images/cw/agent/avatar/11/thumb_myimage.jpg" FATAL -- : ActionCon

我认为:

Rails 4.1
Ruby 2.1.1

但是当我检查时,文件/home/dnc/app/assets/images/cw/agent/avatar/11/thumb_myimage.jpg确实存在。有什么想法吗

路径帮助程序

有人会问,为什么不使用来访问
图像
目录:

INFO -- : Started GET "/home/dnc/app/assets/images/cw/agent/avatar/11/thumb_myimage.jpg"
FATAL -- : 
ActionController::RoutingError (No route matches [GET] "/home/dnc/app/assets/images/cw/agent/avatar/11/thumb_myimage.jpg"):   



我理解你的推理(你想直接访问图像),但我不明白你的方法。Rails有一个非常强大的相对路径系统,它应该让您能够根据需要灵活地访问图像

试试image_tag”/cw/agent/avatar/#{agent.id.to_s}/thumb#{a.img_name}只是一个注释。无需在
{agent.id.to_s}
上调用
到_s
。达米恩:谢谢你的提示。拉胡尔:这行不通,结果会是一样的。实际上,我已经尝试过图像标签“cw/agent/avatar/#{agent.id.to_s}/thumb#{a.img_name}”,但它不起作用。原来我没有清除浏览器的缓存。当我这样做时,它工作得很好。请尝试:
我正在使用,我没有刷新,并且认为它不工作。见上文我对Rahul评论的回复。感谢您提供有关资产路径帮助程序的提示
INFO -- : Started GET "/home/dnc/app/assets/images/cw/agent/avatar/11/thumb_myimage.jpg"
FATAL -- : 
ActionController::RoutingError (No route matches [GET] "/home/dnc/app/assets/images/cw/agent/avatar/11/thumb_myimage.jpg"):   
<% img_loc = image_path("cw/agent/avatar/11/thumb_myimage.jpg") %>
<%= image_tag "cw/agent/avatar/11/thumb_myimage.jpg" %>