>我将图像从公共/图像移动到资产/图像路径
我有图片:
<%= 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') %>