如何将图像移动到资产图像路径时' No route matches [GET] image.png '?



>我将图像从公共/图像移动到资产/图像路径

我有图片:

 <%= image_tag("login_logo.png", :id => "login_logo") %>

我将其从公共文件夹移动到资产并更改了路径。

它是可见的并且工作正常,但是我在控制台中出现错误:

Started GET "/assets/logo_PG.png" for 127.0.0.1 at 2012-10-10 23:42:53 +0300
 Served asset /logo_PG.png - 304 Not Modified (0ms)
ActionController::RoutingError (No route matches [GET] "/images/login_logo.png")

我该如何解决这个问题?

默认情况下,

资产子目录中的所有内容(无论是图像、JS等)都可以在/assets/name.extension下使用。因此,只需确保使用路径引用图像 /assets/login_logo.png ,或使用asset_path助手:

<%= asset_path('login_logo.png') %>

最新更新