如何在rails 4中管理多个css文件? [英] How to manage multiple css files in rails 4?

查看:107
本文介绍了如何在rails 4中管理多个css文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我拥有包含在 app / views / layouts / mycontroller.html.erb 中的控制器下的所有内容的css文件:

I have the css file for everything under a controller included in app/views/layouts/mycontroller.html.erb:

<head>
  <%= stylesheet_link_tag "mysubdirectory/main" %>
</head>

但是我已经将我的css分解为一些特定视图,比如home.css.scss (可能不是最好的分解方式?)。之前,我还额外包含了额外的CSS。例如。在 app / views / mycontroller / home.html.erb 中,我会带着另一个 styleshet_link_tag

But I've decomposed my css into some that are for particular views, like home.css.scss (may not be the best way to break it down?). Before, I was additionally included extra css. E.g. in app/views/mycontroller/home.html.erb, I would lead with another styleshet_link_tag:

<%= stylesheet_link_tag "mysubdirectory/home" %>

我包含 gem'sass-rails','4.0.1' 在我的Gemfile中,并且预编译发生在heroku上。

I am including gem 'sass-rails', '4.0.1' in my Gemfile and the precompiling happens on heroku.

没有一个CSS似乎正在加载或只有一些,而不是总和这两套CSS规则。

None of the CSS seems to be loading or only some of it and not the sum of the two sets of CSS rules.

推荐答案

你需要告诉Rails预编译你的附加文件,在你的application.rb中添加

You need to tell Rails to precompile your additional files, in your application.rb add

config.assets.precompile += ['mysubdirectory/main']



Rails只会预编译application.css和application.js。

Rails will only precompile application.css and application.js by default.

这篇关于如何在rails 4中管理多个css文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆