为什么stylesheet_link_tag在生产中不链接到/assets? [英] Why does stylesheet_link_tag not link to /assets in production?

查看:72
本文介绍了为什么stylesheet_link_tag在生产中不链接到/assets?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我刚为新的Rails 3.1应用程序进行了首次部署,但是资产似乎无法正常工作.我正在部署时对所有内容进行预编译,并且像预期的那样在public/assets中出现.但是,在我的布局中,例如stylesheet_link_tag "application"的输出具有指向/stylesheets/application.css的href.这显然行不通.

I just did the first deploy for a new Rails 3.1 application, but the assets don't seem to work correctly. I'm precompiling everything upon deploy, and it turns up in public/assets like expected. However, the output of for example stylesheet_link_tag "application" in my layout has a href pointing to /stylesheets/application.css. This obviously does not work.

奇怪的是,在开发模式下,一切似乎都很好,它像预期的那样链接到/assets/application.css.

The strange thing is that in development mode everything seems to be fine, it links to /assets/application.css like expected.

我已经将我的config/application.rbconfig/environments/production.rb文件与资产管道中的另一个应用程序进行了比较,并且相关设置似乎相同.

I've compared my config/application.rb and config/environments/production.rb files with another app we have on the asset pipeline, and the relevant settings seem to be the same.

我应该去哪里看?

推荐答案

当助手生成此代码时:

/stylesheets/application.css

这是因为在您所使用的任何模式下都不会启用管道.有多种可能的原因.

This is because the pipeline is NOT enabled in whatever mode you are in. There are several possible reasons.

  • 您在错误的配置文件中启用了管道. (应在application.rb配置文件中启用管道)

  • You have the pipeline enabled in the wrong config file. (The pipeline should be enabled in the application.rb config file)

您已在application.rb中启用了它,并在其他地方禁用了它.

You have it enabled in application.rb and disabled somewhere else.

您不小心在某处注释掉了铁路轨枕

You have accidentally commented out a railtie somewhere

有关详细信息,请参见此问题.

See this question for details.

如果这是升级版应用程序,请检查

If this is an upgraded app, check all the config options in the last section of the pipeline guide to make sure that you have them all correctly set.

这篇关于为什么stylesheet_link_tag在生产中不链接到/assets?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆