stylesheet_link_tag 未链接到 Rails 资产管道中的 /asset
我正在尝试从 Rails 3.0 升级到 Rails 3.1。之前我使用 Jammit 来处理资源,经过相当多的步骤后,我发现除了 CSS 部分之外,一切看起来都相当不错。当我使用 javascript_include_tag
和 image_tag
时,它会在开发中生成指向 /assets
的正确链接,但是当我使用 stylesheet_link_tag
时对于 css,它保留生成的链接到 /stylesheets
而不是 /assets
。
这里有什么问题呢?
有几个与我的问题相关的问题,我已经正确完成了他们所说的一切,但我仍然找不到我的问题的解决方案。相关问题是:
更新
我自己发现了问题,我正在使用的 gem 覆盖了 Raild 资产标签助手的默认行为。
I am trying to upgrade from Rails 3.0 to Rails 3.1. Previously I was using Jammit for assets, after quite a few steps I got to a point where everything looks pretty good except for CSS part. When I use javascript_include_tag
and image_tag
, it generates correct link to /assets
in development , but when I use stylesheet_link_tag
for css, it keeps generated links to /stylesheets
instead of /assets
.
What is the problem here?
There are several questions related to my problem and I have done everything they said correctly, but I still cannot find out the solution for my problem. Related questions are:
- Why does stylesheet_link_tag not link to /assets in production?
- Rails 3.1 assets pipeline in production
Update
I found the problem myself, a gem I am using overrides the default behavior of Raild asset tag helpers.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我遇到了同样的问题,罪魁祸首是旧版本的“mobile-fu”gem。
我使用的是 0.2 版本,升级到 1.1 解决了我的问题。版本 0.2 为“stylesheet_link_tag”方法起了别名,从而干扰了 Sprockets::Helpers::RailsHelpers 模块。我通过在所有 Gems 中查找“stylesheet_link_tag”来查看它可能在哪里被重新定义,从而发现了令人反感的代码。
我希望这对将来遇到这个问题的人有所帮助:)。
I had the same issue and the culprit turned out to be an old version of the 'mobile-fu' gem.
I was using version 0.2, and upgrading to 1.1 solved the issue for me. Version 0.2 aliased the 'stylesheet_link_tag' method in such a way that interfered with the Sprockets::Helpers::RailsHelpers module. I found the offensive bit of code by grepping through all my Gems for the 'stylesheet_link_tag' to see where it may have been redefined.
I hope this helps anyone who comes across this issue in the future :).