First argument in form cannot contain nil or be empty
なるエラーがでました。
原因は
app/views/tasks_/form_html_erbの
<%= form_for(@task) do |f| %> <% if @task.errors.any? %> <div id="error_explanation"> <h2><%= pluralize(@task.errors.count, "error") %> prohibited this task from being saved:</h2> <ul>
の
<%= form_for(@task) do |f| %>
が原因との事。
ググって原因を確認したところ
https://teratail.com/questions/16823
https://teratail.com/questions/63651
などありなんとなくわかりそうですが・・・・・
やはりわかりませんでした
コントローラーを修正する必要がありそうなのがぐぐりから感じるのですが・・・・
わからず・・・
。。。。。。
お知恵を拝借する事は可能でしょうか・・・(><)
ちなみにコントローラーは
class TasksController < ApplicationController before_action :authenticate_user! before_action :set_task, only: [:show, :edit, :update, :destroy] # GET /tasks # GET /tasks.json def index @tasks = Task.where(charge_id: current_user.id) end # GET /tasks/1 # GET /tasks/1.json def show end # GET /tasks/new def new @tasks = Task.where(charge_id: current_user.id) end # GET /tasks/1/edit def edit end # POST /tasks # POST /tasks.json def create @task = current_user.tasks.build(task_params) @task.charge_id = current_user.id respond_to do |format| if @task.save format.html { redirect_to @task, notice: 'Task was successfully created.' } format.json { render :show, status: :created, location: @task } else format.html { render :new } format.json { render json: @task.errors, status: :unprocessable_entity } end end end # PATCH/PUT /tasks/1 # PATCH/PUT /tasks/1.json def update respond_to do |format| if @task.update(task_params) format.html { redirect_to @task, notice: 'Task was successfully updated.' } format.json { render :show, status: :ok, location: @task } else format.html { render :edit } format.json { render json: @task.errors, status: :unprocessable_entity } end end end # DELETE /tasks/1 # DELETE /tasks/1.json def destroy @task.destroy respond_to do |format| format.html { redirect_to tasks_url, notice: 'Task was successfully destroyed.' } format.json { head :no_content } end end private # Use callbacks to share common setup or constraints between actions. def set_task @task = Task.find(params[:id]) end # Never trust parameters from the scary internet, only allow the white list through. def task_params params.require(:task).permit(:user_id, :title, :content, :deadline, :charge_id, :status) end end
となります。
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2017/12/04 12:50
2017/12/04 13:21