Store#index 中的链轮::CircularDependencyError

发布于 2024-12-05 08:12:50 字数 1271 浏览 2 评论 0原文

我正在阅读手册《使用 Rails 进行敏捷 Web 开发》第 4 版,并且在 Rails 3.1 中遇到了 sprocket css 的问题。

代码 css 是:

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

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

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 中的边距值或填充值我收到这个错误。

非常感谢。

I am following the manual Agile Web Development with Rails 4th edition and I have a problem with sprocket css in rails 3.1.

The code css is:

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

If I modify the css code of app/assets/stylesheets/aplication.css.scss I catch the next error:

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'

I dont understand why if I modify a margin value or a padding value in aplication.css.scss for example I get this error.

Thank you very much.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

何处潇湘 2024-12-12 08:12:50

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

You should remove app/assets/stylesheets/application.css.

那小子欠揍 2024-12-12 08:12:50

我遇到了类似的问题:
资产管道不预编译 sass

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

消除:

 *= require_tree .

I had a similar problem:
Asset pipeline not precompiling sass

The circular dependency happens when the manifest file requires the tree files. Sass does this anyway so it's not necessary.

Remove:

 *= require_tree .
淡淡的优雅 2024-12-12 08:12:50

安装 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;
}

I was having this same problem after installing SCSS. I fixed the problem by removing the defult comments that rails places in the header. So this:

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

Became this:

#wrapper {
    width: 980px;
    margin: 0 auto;
}
凉风有信 2024-12-12 08:12:50

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

Just name the application.css as "application.scss". This will solve your problem.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文