css没有应用于rails 4.2.5.1?

时间:2016-02-27 08:41:58

标签: html css ruby-on-rails ruby-on-rails-4.2

“我在rails中生成控制器,它为我生成了css,但是当我在assets / stylesheets中添加css时,控制器名称为controller_name.scss.css,但是当我在html文件中添加它时,它就会到达那里。”

“这是我的controller_name.scss.css文件”

// Place all the styles related to the boo controller here.
// They will automatically be included in application.css.
// You can use Sass (SCSS) here: http://sass-lang.com/
h1 { color:#77eeff;
    text-align: center;
    text-decoration: underline;}

这是application.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 any plugin's vendor/assets/stylesheets directory 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 bottom of the
* compiled file so the styles you add here take precedence over    styles    defined in any styles
* defined in the other CSS/SCSS files in this directory. It is generally better to create a new
* file per style scope.
*
*= require_tree .
*= require_self
*/
/*

1 个答案:

答案 0 :(得分:1)

请更改" controller_name.scss.css"文件到" controller_name.css.scss"据我记忆,预处理器扩展应该在最后链接。此外,如果您的应用程序环境是"生产"然后你必须运行:

bundle exec production rake assets:precompile

如果是开发,那么只需运行:

rake assets:precompile

查看有关资产管道here

的rails指南