简体   繁体   English

在每个视图中都包含Rails中的ruby中的scss文件

[英]Including scss files in ruby on rails for each view

I am developing an application in Ruby on Rails. 我正在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. view/layouts/application.html.erb包含文件的基本布局view/sessions/new.html.erb包含与会话相关的逻辑。 application.html.erb yields to this page. application.html.erb移至该页面。

Now I have used some css styling in my new.html.erb file. 现在,我在new.html.erb文件中使用了一些CSS样式。 I have added the corresponding CSS in in assets/stylesheets/sessions.scss 我在assets/stylesheets/sessions.scss添加了相应的CSS

In my application.html.erb file I have included the css file this way: 在我的application.html.erb文件中,我以这种方式包含了css文件:

<%= 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. 但是,当我查看生成的html文件的源代码时,它显示: sessions.scss.css ,它无法加载该文件。

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 config/initializers assets.rb文件中

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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