Store#index中的Sprockets :: CircularDependencyError

时间:2011-09-18 16:05:00

标签: ruby-on-rails ruby sprockets

我正在关注使用Rails第4版的Agile Web开发手册,我在rails 3.1中遇到链轮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 个答案:

答案 0 :(得分:52)

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

答案 1 :(得分:14)

我遇到了类似的问题:
Asset pipeline not precompiling sass

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

卸下:

 *= require_tree .

答案 2 :(得分:2)

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

/*
 * 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;
}

答案 3 :(得分:0)

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

相关问题