質問をすることでしか得られない、回答やアドバイスがある。

15分調べてもわからないことは、質問しよう!

新規登録して質問してみよう
ただいま回答率
85.48%
Ruby on Rails

Ruby on Railsは、オープンソースのWebアプリケーションフレームワークです。「同じことを繰り返さない」というRailsの基本理念のもと、他のフレームワークより少ないコードで簡単に開発できるよう設計されています。

Q&A

解決済

1回答

2845閲覧

ActionView::SyntaxErrorInTemplateについて

k-hayashi

総合スコア13

Ruby on Rails

Ruby on Railsは、オープンソースのWebアプリケーションフレームワークです。「同じことを繰り返さない」というRailsの基本理念のもと、他のフレームワークより少ないコードで簡単に開発できるよう設計されています。

0グッド

0クリップ

投稿2021/05/16 07:13

前提・実現したいこと

宿泊予約サービスアプリを作成していて、予約内容の入力から予約完了画面に遷移させたい(予約確認画面は作成しません)のですが、syntaxerrorが出ました。うちま

問題となるエラーメッセージ

ActionView::SyntaxErrorInTemplate in ReservationsController#show Extracted source (around line #19): 17 <div class="d-flex"> 18 <%= f.label :start_date, '開始日', class: 'col-md-3' %> 19 <%= reservation.start_date, class: 'col-md-9' %> 20 </div> 21 </div> 22 <div class="row"> Rails.root: /Users/hayashikeiichirou/Desktop/rails2nd/roomshare Application Trace | Framework Trace | Full Trace app/views/reservations/show.html.erb:19: syntax error, unexpected tLABEL, expecting '=' app/views/reservations/show.html.erb:25: syntax error, unexpected tLABEL, expecting '=' app/views/reservations/show.html.erb:31: syntax error, unexpected ',', expecting ')' app/views/reservations/show.html.erb:19: syntax error, unexpected tLABEL, expecting '=' app/views/reservations/show.html.erb:25: syntax error, unexpected tLABEL, expecting '=' app/views/reservations/show.html.erb:31: syntax error, unexpected ',', expecting ')' app/views/reservations/show.html.erb:19: syntax error, unexpected tLABEL, expecting '=' app/views/reservations/show.html.erb:25: syntax error, unexpected tLABEL, expecting '=' app/views/reservations/show.html.erb:31: syntax error, unexpected ',', expecting ')' app/views/reservations/show.html.erb:19: syntax error, unexpected tLABEL, expecting '=' app/views/reservations/show.html.erb:25: syntax error, unexpected tLABEL, expecting '=' app/views/reservations/show.html.erb:31: syntax error, unexpected ',', expecting ')' app/views/reservations/show.html.erb:19: syntax error, unexpected tLABEL, expecting '=' app/views/reservations/show.html.erb:25: syntax error, unexpected tLABEL, expecting '=' app/views/reservations/show.html.erb:31: syntax error, unexpected ',', expecting ')' app/views/reservations/show.html.erb:19: syntax error, unexpected tLABEL, expecting '=' app/views/reservations/show.html.erb:25: syntax error, unexpected tLABEL, expecting '=' app/views/reservations/show.html.erb:31: syntax error, unexpected ',', expecting ')'

該当のソースコード

<%= render 'users/host' %> <div class="container-fiuld user"> <div class="row"> <div class="d-flex"> <div class="col-md-12 user-view"> <div class="user-view-box"> <% form_with(model: @reservation) do |f| %> <% @reservations.each do |reservation| %> <div class="update-content"> <div class="row"> <div class="d-flex"> <%= f.label :room_name, '予約した部屋', class: 'col-md-3' %> <%= link_to reservation.room_name, user_room_path(@room.id), class: "col-md-9" %> </div> </div> <div class="row"> <div class="d-flex"> <%= f.label :start_date, '開始日', class: 'col-md-3' %> <%= reservation.start_date, class: 'col-md-9' %> </div> </div> <div class="row"> <div class="d-flex"> <%= f.label :end_date ,'終了日', class: 'col-md-3' %> <%= reservation.end_date, class: 'col-md-9' %> </div> </div> <div class="row"> <div class="d-flex"> <%= f.label :total_price ,'価格', class: 'col-md-3' %> <%= reservation.price * reservation.number_of_people, class: 'col-md-9' %> </div> </div> </div> <% end %> <% end %> </div> </div> </div> </div> </div> <div> <ul> <li><%= f.submit '登録完了する' %><li> <li><%= link_to "トップ画面に戻る", user_path(current_user.id) %></li> </ul> </div>

試したこと

下記のサイトを参考にしましたが解決できませんでした。

気になる質問をクリップする

クリップした質問は、後からいつでもMYページで確認できます。

またクリップした質問に回答があった際、通知やメールを受け取ることができます。

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

guest

回答1

0

ベストアンサー

エラーメッセージのとおりです。<%= reservation.start_date, class: 'col-md-9' %>が文法的に成立していません。

投稿2021/05/16 07:19

maisumakun

総合スコア145184

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

k-hayashi

2021/05/16 07:36

<div class="col-md-9"> <%= reservation.start_date %> </div> にしたら解決しました。初歩的なミスでした。ありがとうございます。
guest

あなたの回答

tips

太字

斜体

打ち消し線

見出し

引用テキストの挿入

コードの挿入

リンクの挿入

リストの挿入

番号リストの挿入

表の挿入

水平線の挿入

プレビュー

15分調べてもわからないことは
teratailで質問しよう!

ただいまの回答率
85.48%

質問をまとめることで
思考を整理して素早く解決

テンプレート機能で
簡単に質問をまとめる

質問する

関連した質問