简体   繁体   中英

Including scss files in ruby on rails for each view

I am developing an application in Ruby on Rails. view/layouts/application.html.erb contains the basic layout of the file view/sessions/new.html.erb contains logic related to session. application.html.erb yields to this page.

Now I have used some css styling in my new.html.erb file. I have added the corresponding CSS in in assets/stylesheets/sessions.scss

In my application.html.erb file I have included the css file this way:

<%= stylesheet_link_tag "sessions.scss" %>

However when I look at the source code of the html file generated it shows: sessions.scss.css and it is not able to load the file.

What is the correct procedure?

I solved this by adding

Rails.application.config.assets.precompile += %w( sessions.css )

in my assets.rb file in config/initializers

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM