html - css 没有在 rails 4.2.5.1 中应用?

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

“我在 rails 中生成 Controller ,它会为我生成 css,但是当我在 Assets /样式表 controller_name.scss.css 中添加 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
*/
/*

最佳答案

请将“controller_name.scss.css”文件更改为“controller_name.css.scss”,据我所知,预处理器扩展应该链接在末尾。此外,如果您的应用程序环境是“生产环境”,那么您必须运行:

bundle exec production rake assets:precompile

如果是开发,那么就运行:

抽取 Assets :预编译

查看有关 Assets 管道的 Rails 指南 here

关于html - css 没有在 rails 4.2.5.1 中应用?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35667616/

相关文章:

javascript - AngularJS中单个路由器的多个 View

javascript - 防止 Jquery-UI 在 Bootstrap 导航栏中更改样式

javascript - 在 Jquery 中单击和未单击元素时不同的悬停颜色

ruby-on-rails - 活跃商家 - 未初始化常量 ActiveSupport::XmlMini_REXML::StringIO

html - 如何从按钮上的链接中删除下划线?

html - 在由文本和图像组成的 html 标签中隐藏文本

html - 外部 CSS 样式表不工作。

php - 无法更改高度和宽度输入类型文本区域

ruby-on-rails - 尝试发送 Javascript 资源时出现 InvalidCrossOriginRequest

jquery - 从 Backstretch 图像建立链接?