css - Rails Assets 位于子目录中,无法在生产环境中加载

标签 css ruby-on-rails production-environment

目前,我的事件 CSS 位于 app/assets/stylesheets/pages/events.scss 中,在开发模式下它看起来不错, Assets 已加载。但是在生产环境中,这些页面似乎根本没有加载。我不确定如何解决这个问题。我看过 Rails 4: assets not loading in production但我不熟悉 config.assets.precompile += %w( *.js ^[^_]*.css *.css.erb) 因为路径本身似乎不是在生产中工作。

应用程序/ Assets /样式表/application.scss:

/*
 * This is a manifest file that'll be compiled into application.css, which will include all the files
 * listed below.
 *


 *#= require bootstrap-wysihtml5
 *#= require rails_bootstrap_forms
 *#= require jquery.jcrop
 *= require custom
 *= require_self 
*/

@import "bootstrap-sprockets";
@import "bootstrap";
@import "scaffolds";

应用程序/views/events/index.html.erb:

<% content_for :head do %>
  <%= stylesheet_link_tag "pages/events", :media => "all" %>
<% end %>

app/assets/stylesheets/pages/events.scss

@import "globals/helpers";
@import "vendors/animate";

.events-bar {
/*  a[class*="btn"] {
  height: 36px;
  display: inline-block;
}*/
#toggleBar {
  margin-top: 14px;
}
.btn-dashboard { 
   background-color: #fdf9ff;
   color: $eventsColour !important;  
   &:hover {
     background-color: $eventsColour-dark !important;
   }
 }
}

它很难调试,因为它在开发中运行良好,但在生产中运行不佳。看起来子目录 (app/assets/stylesheet/pages/*.scss) 中的所有文件在生产环境中都不起作用。任何见解都会有所帮助,谢谢。

最佳答案

你只需要将事件添加到你的预编译 Assets 列表中,因为它不是用 application.scss 编译的,你想要的格式是

config.assets.precompile += %w( pages/events.scss )

然后

bundle exec rake assets:precompile

关于css - Rails Assets 位于子目录中,无法在生产环境中加载,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38196678/

相关文章:

html - 背景大小不起作用。我该如何解决明显的问题?

javascript - 如何为内容不断被替换的段落设置字体大小

ruby-on-rails - Log4r : logger inheritance, yaml 配置,替代方案?

java - 使用JSP有什么优点? (java服务器页面)

ruby-on-rails - Ruby/Rails - 向网站添加投票

error-handling - 当您的软件在现场崩溃时,您会捕获哪些信息?

javascript - fieldset-css 以输入为中心

jquery - .height() .width() 不会根据尺寸变化进行调整

ruby-on-rails - 如何在生产模式下启动延迟工作 worker

ruby-on-rails - Webrick 作为生产服务器与 Thin 或 Unicorn?