(環境)
①Ruby ver 2.5.0
②Rails ver 5.2.1
③DB Mysql
(状況)
シンプルなTo_doタスクアプリを作成しています。新規投稿ページ作成時に、Railsの機能である「form_with」が機能しなくなったのか、ブロックで渡した引数fが認識されません。この原因はなんなのでしょうか?
①app/views/tasks/new.html.slim
rails
1h1 タスクの新規登録 2 3.nav.justify-content-end 4 = link_to '一覧', tasks_path, class: 'nav-link' 5 6 = form_with model: @task, local: true do |f| 7 .form-group 8 = f.label :name 9 = f.text_field :name, class: 'form-control', id: 'task_name' 10 .form-group 11 = f.label :description 12 = f.text_area :description, rows: 5, class: 'form-control', id: 'task_description' 13 = f.submit nil, class: 'btn btn-primary'
②controller
rails
1class TasksController < ApplicationController 2 def index 3 end 4 5 def show 6 end 7 8 def new 9 @task = Task.new 10 end 11 12 def edit 13 end 14end
③エラーコード
rails
1NameError in Tasks#new 2undefined local variable or method `f' for #<#<Class:0x00007f96b36a0030>:0x00007f96b9ac34e0>
よろしくお願いしますm(__)m
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2018/11/14 09:42
2018/11/14 09:46