私はRailsの初心者です。私は入れ子にしようとしている。私は仕事があり、それぞれに仕事が割り当てられていますが、私は更新作業をしようとするとエラーが発生しますNo route matches [PATCH] "/ jobs/2/tasks"
[PATCH] "/ jobs/2/tasks"と一致するルートはありません
私は経路を変更する必要がありますか?事前に
おかげ
マイルート
Rails.application.routes.draw do
root 'jobs#index'
resources :sessions
resources :users
resources :jobs do
resources :tasks
end
match 'jobs/:job_id/tasks', to: "jobs/tasks#index", via: :get
get 'admin' => 'jobs#index'
end
タスク/フォーム
<%= form_for @task, url: job_tasks_path do |f| %>
<% if @task.errors.any? %>
<div id="error_explanation">
<h2><%= pluralize(@task.errors.count, "error") %> prohibited this post from being saved:</h2>
<ul>
<% @task.errors.full_messages.each do |message| %>
<li><%= message %></li>
<% end %>
</ul>
</div>
<% end %>
<div class="field">
<%= f.label :text %><br>
<%= f.text_area :text %>
</div>
<div class="actions">
<%= f.submit %>
</div>
<% end %>
タスクコントローラのすべての
def update
respond_to do |format|
if @task.update(task_params)
format.html { redirect_to job_tasks_url, notice: 'Zadanie zostało pomyslnie zmienione.' }
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
ありがとうございました! – kisiel