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

How to use stylesheet_link_tag with sprockets 4?

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

I have file app/assets/stylesheets/themes/plexa/home.sass

  1. Added to config/manifest.js

    //= link themes/plexa/home.css

  2. Check http://localhost:3000/assets/themes/plexa/home.css - It works, I see css!

  3. But if I add to rails layout:

stylesheet_link_tag "themes/plexa/home" This doesn't work!

It raise rails exception: ActionView::Template::Error at / themes/plexa/home.css

Tried with debugger:

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

I read all sprockets docs and upgrade guide but doesn't understand why stylesheet_link_tag doesn't works ( Rails 5.1)

Update: = stylesheet_link_tag "/assets/themes/plexa/home" Works, but I doesn't understand why I need to setup assets path?

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

Update: Sprockets has not been updated that's why manifest.js ignored because there is an old ruby version 2.4.6, which need to update