Rails:为什么我的所有scss文件都没有编译? [英] Rails: Why doesnt all my scss files get compiled?

查看:73
本文介绍了Rails:为什么我的所有scss文件都没有编译?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是Rails的初学者,我认为对于如何组织样式表还没有一个明确的想法.目前,我的资产/样式表中有两个文件:

I am a beginner in rails, and I reckon I haven't got a clear idea on to how the stylesheets should be organised. Currently, I have two files in my assets/stylesheets:

  • application.css
  • home.css

当我运行rake asset:precompile时-我意识到只有application.css被编译到我的public/assets文件夹中.那么home.css呢?

When I run rake assets:precompile - I realise that only application.css is compiled into my public/assets folder. What about home.css?

更多信息

我希望仅当从我的家庭控制器收到响应时才加载home.css.我已经删除* = require_tree.来自application.css(因为我猜想home.css会包含在所有其他页面中-是吗?)

I want home.css to load only when the respond is received from my home controller. I have removed *= require_tree . from application.css (since I am guessing that home.css would be included in all other pages - am I right?)

我要为此寻求解决方案的原因是,因为heroku引发以下错误:

The reason I am trying to figure out a solution for this is because heroku throws the following error:

ActionView::Template::Error (home.css isn't precompiled):
2012-04-29T10:48:20+00:00 app[web.1]:     5:     <meta name="viewport" content="width=device-width">
2012-04-29T10:48:20+00:00 app[web.1]:     7:     = stylesheet_link_tag "application"
2012-04-29T10:48:20+00:00 app[web.1]:     6:     = javascript_include_tag "application"
2012-04-29T10:48:20+00:00 app[web.1]:     8:     = stylesheet_link_tag params[:controller]
2012-04-29T10:48:20+00:00 app[web.1]:     9:     = javascript_include_tag [:controller]
2012-04-29T10:48:20+00:00 app[web.1]:     10:     = csrf_meta_tags
2012-04-29T10:48:20+00:00 app[web.1]:     11:   %body
2012-04-29T10:48:20+00:00 app[web.1]: 
2012-04-29T10:48:20+00:00 app[web.1]:   app/views/layouts/application.haml:8:in `_app_views_layouts_application_haml__2082158123561350666_35885340'
2012-04-29T10:48:20+00:00 app[web.1]: cache: [GET /] miss

任何想法是什么问题/错误?谢谢!

Any ideas what the problem/mistake is? Thanks!

推荐答案

默认情况下,仅application.css可以编译(请参见指南).如果要更改预编译的内容,请在application.rb中更改 config.assets.precompile ,例如

By default only application.css is compile (see the guide). If you want to change what is precompiled, change config.assets.precompile in application.rb, for example

config.assets.precompile += ['home.css']

这篇关于Rails:为什么我的所有scss文件都没有编译?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆