Warm tip: This article is reproduced from serverfault.com, please click

ruby on rails-如何在链轮4中使用stylesheet_link_tag?

(ruby on rails - How to use stylesheet_link_tag with sprockets 4?)

发布于 2020-11-28 12:48:18

我有文件app / assets / stylesheets / themes / plexa / home.sass

  1. 添加到config / manifest.js

    // =链接主题/plexa/home.css

  2. 检查http://localhost:3000/assets/themes/plexa/home.css-可以,我看到CSS!

  3. 但是,如果我添加到rails布局:

stylesheet_link_tag "themes/plexa/home" 这行不通!

它引发了Rails异常:/ themes / plexa / home.css上的ActionView :: Template :: Error

尝试使用调试器:

byebug) stylesheet_link_tag "themes/plexa/home"
*** Sprockets::Rails::Helper::AssetNotPrecompiled Exception: themes/plexa/home.css

我阅读了所有链轮文档和升级指南,但不明白为什么stylesheet_link_tag不起作用(Rails 5.1)

更新: = stylesheet_link_tag“ / assets / themes / plexa / home”可行,但是我不明白为什么我需要设置资产路径?

Questioner
Ruslan Coroliov
Viewed
0
Ruslan Coroliov 2020-11-28 22:32:05

更新:链轮尚未更新,这就是为什么manifest.js被忽略的原因,因为有一个旧的ruby版本2.4.6,需要更新