18

Rails 4th edition を使用したマニュアル Agile Web Development に従っていますが、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 に答える