gpt4 book ai didi

ruby-on-rails - 没有路由匹配 [GET] "/stylesheets/frontend.css"

转载 作者:行者123 更新时间:2023-12-03 15:10:07 24 4
gpt4 key购买 nike

ruby 版本:2.0.0

Rails 版本:4.0.1

这是我之前问题的后续问题:Why do assets fail to load in production mode? .这主要是通过在 production.rb 中设置 config.serve_static_assets = true 来解决的。

但是,现在我仍然有一个样式表和一个没有被引入的 javascript 文件。这(巧合的是)应该引入它自己的一组依赖项。

在我的 application.html.erb 文件中我有:

<%= stylesheet_link_tag "application", media: "all"  %>
<%= stylesheet_link_tag "frontend", media: "all" %>

但是,这似乎解析为两个非常不同的东西。这是输出:

<link href="/assets/application-1c1eb49916824f465443a709172a580a.css" media="all" rel="stylesheet">
<link href="/stylesheets/frontend.css" media="all" rel="stylesheet">

如果它有所不同,这就是 frontend.css 的实际样子:

/*
* This is a manifest file that'll be compiled into application.css, which will include all the files
* listed below.
*
* Any CSS and SCSS file within this directory, lib/assets/stylesheets, vendor/assets/stylesheets,
* or vendor/assets/stylesheets of plugins, if any, can be referenced here using a relative path.
*
* You're free to add application-wide styles to this file and they'll appear at the top of the
* compiled file, but it's generally better to create a new file per style scope.
*
*= require_self
*= require_tree ./frontend
*= require front_end
*/

我错过了什么?

最佳答案

config/application.rb中,添加frontend.cssconfig.assets.precompile:

# Precompile additional assets (application.js, application.css, and all non-JS/CSS are already added)
config.assets.precompile += %w( frontend.css )

如果您创建其他 CSS 和 JavaScript list 文件,请不要忘记执行此操作。

关于ruby-on-rails - 没有路由匹配 [GET] "/stylesheets/frontend.css",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23123586/

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