Q&A
実現したいこと
ActionView::SyntaxErrorInTemplate in UsersController#index
のエラーを修正する
前提
Ruby on Railでアプリを作っています。
ユーザー機能を実装中に以下のエラーメッセージが発生しました。
ユーザー一覧ページを作ろうと思い、usersコントローラーとindexアクションを作成、usersテーブルに入っているユーザーの名前をすべて表示するようにしたところエラーが出ました。
発生している問題・エラーメッセージ
ActionView::SyntaxErrorInTemplate in UsersController#index Encountered a syntax error while rendering template: check <% @users.each do |user| %> <%= user.email %>
Extracted source (around line #4): 2 <%= user.email %>
Exception Causes SyntaxError: /Users/〇〇/△△/アプリ名/app/views/users/index.html.erb:4: syntax error, unexpected end-of-input, expecting `end' end ^
該当のソースコード
app/views/users/index.html.erb
ruby
1<% @users.each do |user| %> 2<%= user.name %>
app/controllers/users_controller.rb
ruby
1class UsersController < ApplicationController 2 def index 3 @users = User.all 4 end 5end
試したこと
Progateを参考にしており、スペルミスやスペースミスなどはないか確認しましたが特になく原因が不明です。教えていただけますと幸いです。
補足情報(FW/ツールのバージョンなど)
Rails7
回答1件
あなたの回答
tips
プレビュー
下記のような回答は推奨されていません。
このような回答には修正を依頼しましょう。