前提
urlにnew.html.erbに遷移するためのパスを直接入力してnew.html.erbに遷移した直後に、
18行目で syntax error, unexpected tIDENTIFIER, expecting end
51行目で syntax error, unexpected end, expecting end-of-input
こちらのエラーが起こってしまいました。
実現したいこと
エラーを解消し、form_forで作成している部分を表示できるようにしたいです。
発生している問題・エラーメッセージ
https://gyazo.com/83000f2ea02cd6e433c857b0ee377b0c
https://gyazo.com/623bcbd580e98a6b14055c72cd0ac7b6
該当のソースコード
routes.rb
Rails.application.routes.draw do devise_for :users root to: "home#index" resources :users resources :informations do resources :details end end
details_controller.rb
class DetailsController < ApplicationController def index end def new @information = Information.new(params[:detail]) @detail = Detail.new end def create @detail = Detail.new(detail_params) if @detail.save redirect_to information_detail_path(@information, @detail) else render :new end end def show end def edit end private def datail_params params.require(:detail).permit(:information_id, :rice, :medicine, :vaccination, :vaccination_image, :weight, :motion, :snack, :remarks) end end
new.html.erb
<section class="hero is-warning"> <div class="hero-body"> <div class="container"> <h1 class="title"> ペットの記録 </h1> </div> </div> </section> <section class="section"> <div class="container"> <div class="columns is-centered"> <div class="column is-6"> <%= form_for @detail local: true do |f| %> <%= f.label :rice, "ご飯", class: "label" %> <%= f.text_field :rice, class: "input is-success" %> <%= f.label :medicine, "処方薬", class: "label" %> <%= f.text_field :medicine, class: "input is-success" %> <%= f.label :vaccination, "ワクチン接種の有無", class: "label" %> <%= f.text_field :vaccination, class: "input is-success" %> <%= f.label :vaccination_image, "ワクチン接種証明", class: "label" %> <%= f.attachment_field :vaccination_image, class: "input is-success" %> <%= f.label :weight, "体重", class: "label" %> <%= f.text_field :weight, class: "input is-success" %> <%= f.label :motion, "運動", class: "label" %> <%= f.text_field :motion, class: "input is-success" %> <%= f.label :snack, "お菓子", class: "label" %> <%= f.text_field :snack, class: "input is-success" %> <%= f.label :remarks, "備考", class: "label" %> <%= f.text_field :remarks, class: "input is-success" %> <%= f.submit "投稿", class: "button is-success" %> <% end %> </div> </div> </div> </section>
試したこと
endタグがないことでエラーが起きているのかと思い、探しましたがみつかりませんでした。
わかる方がいましたら教えていただけますと幸いです。
よろしくお願いいたします。
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2022/05/12 14:14
2022/05/12 17:00
2022/05/13 00:42
2022/05/13 00:56
2022/05/13 02:48
2022/05/13 12:30 編集
2022/05/16 05:21
2022/05/16 05:41 編集