我将它从公用文件夹移动到 Assets 并更改了路径。 它是可见的并-6ren">
gpt4 book ai didi

ruby-on-rails - 将图像移动到 Assets 图像路径时如何解决 ' No route matches [GET] image.png '?

转载 作者:行者123 更新时间:2023-12-04 06:09:53 24 4
gpt4 key购买 nike

我将图片从 public/images 移动到 assets/images 路径

我有图片:

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

我将它从公用文件夹移动到 Assets 并更改了路径。

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

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")

我该如何解决这个问题?

最佳答案

assets 子目录中的所有内容(无论是图片、JS 等)默认情况下都位于 /assets/name.extension 下。因此,只需确保使用路径 /assets/login_logo.png 引用图像,或使用 asset_path 助手:

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

关于ruby-on-rails - 将图像移动到 Assets 图像路径时如何解决 ' No route matches [GET] image.png '?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12827813/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com