LoginSignup
20
11

More than 3 years have passed since last update.

actionview::syntaxerrorintemplate in [コントローラ名]controller#indexエラーについて

Posted at

actionview::syntaxerrorintemplateエラーについて

エラー文.png

このようにビューが乱れに乱れている時は

「ビューをコメントアウトした時に余分な%や,を消してしまった」

という事が考えられますのでまずは該当のビューが正しいかどうかを見るのがポイント!

次に考えられるのはController#indexアクションの定義が合っているのかどうか。

要するに「Controller#index」⇄「indexのビュー」間で「読み込めないよ〜😭」と怒られている状況です。MVC.png

                      ⬆️

2fa33af89e7d40798ff996ca953346f9.png

上記の画像のエラー内容は「indexアクションでビューに飛んだけど、23行目の構文が間違っているからこの後のコードを読み込めなかったよ😠」と怒られています。

before

◯◯.html.erb
<%= link_to '新規登録', new_user_registration_path  class: "sign-up" %>

after

◯◯.html.erb
<%= link_to '新規登録', new_user_registration_path,  class: "sign-up" %>

という事で 「,」 が抜けているだけでした、、、

まとめ

エラー文は意味をなんとなくな日本語に変換する事がポイントです!直訳をしろ!とか正確に!ではなく、「なんとなくここかここだろうな」という考察力を養って、エラー文に慣れればへっちゃらですし、エラー文が次から次へと出る😭ではなく、1つずつコンピュータがコードを読み込んでくれている証なので前向きに考えましょう!!

20
11
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
20
11