2

我在视图中将图像源指定为<img src="assets/grid2Whitepressed.png" />. 文件名为 index.html.erb 文件,是 billings 控制器的一部分。我为此收到路由错误

Started GET "/billings/assets/grid2Whitepressed.png" for 127.0.0.1 at 2013-09-05
 17:33:36 +0530

ActionController::RoutingError (No route matches [GET] "/billings/assets/grid2Wh
itepressed.png"):

我是 Rails 新手,所以不确定这是否需要在路由文件中明确定义。我检查了很多帖子,但没有提到我们也必须为资产定义路线。我检查了 application.rb、development.rb 文件设置,一切都如 ROR 网站上所述。请指教。谢谢。

4

2 回答 2

4

显然,您的路线开始的路径是 /billing。尝试这个:

 <img src="../assets/grid2Whitepressed.png" />
于 2013-09-05T12:25:07.600 回答
1
<img src="/assets/yourimage.png"></img>

始终为您的路径提供父目录名称。

于 2013-09-05T12:27:37.560 回答