我认为在 Rails 3.2 中使用 Sprockets 执行此操作的“默认”方法是使用名为 application.css 的文件(不是 application.css.scss),其中包含您的 Sprockets 清单代码。应该看起来像这样......
application.css(应用程序/资产/样式表)
/*
* This is a manifest file that'll automatically include all the stylesheets available in this directory
* and any sub-directories. 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 main_scss_file
*/
至少应该有两行,第一行应该是 require_self,它在自身内部添加内容,以及 require some_other_file,它是对您的主 scss 文件的引用。rake assets:precompile 的默认行为是编译您的 application.js 和 application css
Rail 生成器生成的 production.rb 编码指定默认编译 application.css。(配置/环境)
# Precompile additional assets (application.js, application.css, and all non-JS/CSS are already added)
# config.assets.precompile += %w( search.js )
config.assets.precompile += %w( home.js )
应用程序.erb
<%= stylesheet_link_tag 'application' %>