gpt4 book ai didi

css - Rails 生产不显示背景图像

转载 作者:行者123 更新时间:2023-11-28 16:14:30 25 4
gpt4 key购买 nike

我的图像未在生产中显示(链接 here)。

我的代码:

_header.html.erb

<%if action_name == 'index' %>
<div class="main_header_bg" id="main_head">
<% end %>
<header id='header'>
<div class="container">
<div class="logo">
<%= link_to image_tag('logo.png'), root_path%>
</div>

主.css

.main_header_bg {
background-image: url(/header_bg.jpg);
-webkit-background-size: 100% 100%;
background-size: 100% 100%;
height: 718px;

生产.log

ActionController::RoutingError (No route matches [GET] "/assets/images/header_bg.jpg"):

图片目录:

  1. 应用程序/ Assets /图像/
  2. 公共(public)/ Assets /图像/

最佳答案

您是否预编译了 Assets ?显式在生产环境中?这是第一次将 Rails 元素投入生产的人们遇到的一个非常典型的问题。

如果没有,运行以下命令:RAILS_ENV=production bundle exec rake assets:precompile

请记住,实际文件正在此处写入,您需要重新上传您的应用程序才能使更改生效。

关于css - Rails 生产不显示背景图像,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37751830/

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