使用rails 4资产管道找不到预编译的CSS文件

时间:2022-01-25 01:16:54

I'm starting in rails and I've got an application that is working in dev (webrick).

我开始使用rails并且我有一个在dev(webrick)中运行的应用程序。

The problem is: the precompiled CSS file is not found in production.

问题是:在生产中找不到预编译的CSS文件。

Now I host it on heroku and deploy it. I have a message saying that assets are precompiled (so it's not a compilation error) and everything is by-default for settings.

现在我将它托管在heroku上并进行部署。我有一条消息说资产是预先编译的(因此它不是编译错误)并且默认设置都是一切。

I've ls the /public/assets folder and everything is in there. I can even cat the application-*.css file and I get the full content I should have.

我有/ public / assets文件夹,一切都在那里。我甚至可以抓住应用程序 - * .css文件,我得到了我应该拥有的全部内容。

Now when I try to access the CSS file it gives me an error 404 (even tho it's an auto-generated css link using <%= stylesheet_link_tag "application", :media => "all" %>). So definetly it's not a problem that I did hardcode the CSS link.

现在,当我尝试访问CSS文件时,它给出了一个错误404(即使它是使用<%= stylesheet_link_tag“application”的自动生成的css链接,:media =>“all”%>)。因此,我确实对CSS链接进行了硬编码并不是问题。

I'm not exactly sure on what would be the next check to perform.

我不确定下一次检查的执行情况。

If you're curious on the output, it is currently publicly accessible here.

如果您对输出很好奇,那么它目前可以在这里公开访问。

2 个解决方案

#1


14  

Try changing the configuration option config.serve_static_assets = false to config.serve_static_assets = true in your config/environments/production.rb if you haven't already done that.

如果您还没有这样做,请尝试在config / environments / production.rb中将配置选项config.serve_static_assets = false更改为config.serve_static_assets = true。

#2


1  

The only thing that fixed it for me in Rails 4 was

在Rails 4中唯一能解决它的问题是

config.assets.compile = true

in config/environments/production.rb

在config / environments / production.rb中

This would fall back to the assets pipeline if a precompiled asset is missed, according to the documentation.

根据文档,如果遗漏了预编译资产,这将回退到资产管道。

#1


14  

Try changing the configuration option config.serve_static_assets = false to config.serve_static_assets = true in your config/environments/production.rb if you haven't already done that.

如果您还没有这样做,请尝试在config / environments / production.rb中将配置选项config.serve_static_assets = false更改为config.serve_static_assets = true。

#2


1  

The only thing that fixed it for me in Rails 4 was

在Rails 4中唯一能解决它的问题是

config.assets.compile = true

in config/environments/production.rb

在config / environments / production.rb中

This would fall back to the assets pipeline if a precompiled asset is missed, according to the documentation.

根据文档,如果遗漏了预编译资产,这将回退到资产管道。