18

我正在关注手册 Agile Web Development with Rails 4th edition,但我在 rails 3.1 中遇到了 sprocket css 的问题。

代码css是:

http://media.pragprog.com/titles/rails4/code/rails31/depot_e/app/assets/stylesheets/application.css.scss

如果我修改 app/assets/stylesheets/aplication.css.scss 的 css 代码,我会发现下一个错误:

Sprockets::CircularDependencyError in Store#index

Showing /home/ubuntu/Desktop/Depot/app/views/layouts/application.html.erb where line #5 raised:

/home/ubuntu/Desktop/Depot/app/assets/stylesheets/application.css.scss has already been required
Extracted source (around line #5):

2: <html>
3: <head>
4:   <title>Pragprog Books Online Store</title>
5: <%= stylesheet_link_tag "application" %>
6: <%= javascript_include_tag "application" %>
7: <%= csrf_meta_tag %>
8: </head>
Rails.root: /home/ubuntu/Desktop/Depot

Application Trace | Framework Trace | Full Trace
app/views/layouts/application.html.erb:5:in`_app_views_layouts_application_html_erb___1008723970_81658620'

我不明白为什么如果我修改 aplication.css.scss 中的边距值或填充值,例如我会收到此错误。

非常感谢你。

4

4 回答 4

52

您应该删除 app/assets/stylesheets/application.css。

于 2011-10-02T21:45:55.233 回答
14

我有一个类似的问题:
资产管道没有预编译 sass

当清单文件需要树文件时,就会发生循环依赖。Sass 无论如何都会这样做,所以没有必要。

消除:

 *= require_tree .
于 2012-01-11T01:29:44.340 回答
2

安装 SCSS 后我遇到了同样的问题。我通过删除 rails 放置在标题中的默认注释解决了这个问题。所以这:

/*
 * 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 vendor/assets/stylesheets of plugins, if any, 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 top of the
 * compiled file, but it's generally better to create a new file per style scope.
 *
 *= require_self
 *= require_tree .
*/

#wrapper {
    width: 980px;
    margin: 0 auto;
}

变成了这样:

#wrapper {
    width: 980px;
    margin: 0 auto;
}
于 2012-01-02T17:54:21.350 回答
0

只需将 application.css 命名为“application.scss”。这将解决您的问题。

于 2015-03-14T17:28:04.710 回答