3
4

More than 3 years have passed since last update.

Sprockets::DoubleLinkError

Posted at

初心者です。備忘録のため。残します。
超基本的な内容です。

エラー内容

Sprockets::DoubleLinkError

Rails にて erb ファイルを作成して、表示しようとしたら上記発生。ターミナル確認すると以下記述あり。

ActionView::Template::Error (Multiple files with the same output path cannot be linked ("style.css")
In "/Users/○○/git/photo_submission/app/assets/config/manifest.js" these files were linked:
  - /Users/○○/git/photo_submission/app/assets/stylesheets/style.css
  - /Users/○○/git/photo_submission/app/assets/stylesheets/style.scss
):

原因

調べてみたら、Rails は rails new したときに自動で作成される views/layauts/application.html.erb を参照して HTML ファイルを作るようです。

Sprocketsの仕組み - Qiita

Rails初学者がつまずきやすい「アセットパイプライン」

assets ファイル以下のデータ群を一つに圧縮する(アセットパイプライン)。

views/layauts/application.html.erb

<%= stylesheet_link_tag 'application', media: 'all', 'data-turbolinks-track': 'reload' %>

 あとで erb ファイルに変更しようと思って、先に普通の HTML ファイルで作成しており、深く考えずに style.scss を作成していた。VSCode の拡張機能の Live Sass Compiler でstyle.css も自動で作成されており、これがエラーの原因。

assets/stylesheets/application.css に style.scss の記述を写し、stylesheets 直下には application.css だけ残すようにファイルの構造を調整して、再度出力すると問題なく表示できた。

3
4
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
3
4