如何使rails加载多个css文件

时间:2014-01-17 19:20:35

标签: css ruby-on-rails

我曾经把所有东西放到application.css中,然后才有效。但现在我想在我的应用程序中使用一些不错的下拉菜单,而css就是huuge。所以我为application.css所在的同一文件夹中的下拉菜单创建了一个新的css文件:stylesheets

现在看来rails并没有加载新创建的css文件。如何让它加载文件夹中的每个文件?

2 个答案:

答案 0 :(得分:2)

使用默认的application.css文件,它包含资产目录中的所有.css文件:

/*
 * This is a manifest file that'll be compiled into application.css, which will include all the files
 * listed below.
 *
 * Any CSS and SCSS file within this directory, lib/assets/stylesheets, vendor/assets/stylesheets,
 * or vendor/assets/stylesheets of plugins, if any, can be referenced here using a relative path.
 *
 * You're free to add application-wide styles to this file and they'll appear at the top of the
 * compiled file, but it's generally better to create a new file per style scope.
 *
 *= require_self
 *= require_tree .
 */

答案 1 :(得分:1)

将这两行放入application.css:

*= require_self
*= require_tree .

*= require tree .将要求app/assets/stylesheetslib/assets/stylesheetsvendor/assets/stylesheets

中的所有css文件