私はレールに不慣れで、非常に単純な問題だと思うものを抱えています。
「タスク」のリストがあります。タスクをクリックすると、データベース内の行を更新して、タスクを完了としてマークします(「ステータス」列を0から1に変更します)。
私の見解では、リンクは次のようになります。
<td><%= link_to t.name, change_task_status_path(:id => t.id) %>
そして、これが私のtasks_controller.rbにあるものです:
def change_task_status
@t = Task.find_by_id(params[:id])
@t.status = '1' # 1 = complete
@t.save
render :nothing => true
end
リンクを正しくフォーマットする方法がわかりません!ビューをロードすると、次のエラーが発生します。
undefined method `change_task_status_path' for #<#<Class:0x3a6c144>:0x3a69d54>
レーキルートの編集は次のことを示しています。
tasks GET /tasks(.:format) tasks#index
POST /tasks(.:format) tasks#create
new_task GET /tasks/new(.:format) tasks#new
edit_task GET /tasks/:id/edit(.:format) tasks#edit
task GET /tasks/:id(.:format) tasks#show
PUT /tasks/:id(.:format) tasks#update
DELETE /tasks/:id(.:format) tasks#destroy
phases GET /phases(.:format) phases#index
POST /phases(.:format) phases#create
new_phase GET /phases/new(.:format) phases#new
edit_phase GET /phases/:id/edit(.:format) phases#edit
phase GET /phases/:id(.:format) phases#show
PUT /phases/:id(.:format) phases#update
DELETE /phases/:id(.:format) phases#destroy
projects GET /projects(.:format) projects#index
POST /projects(.:format) projects#create
new_project GET /projects/new(.:format) projects#new
edit_project GET /projects/:id/edit(.:format) projects#edit
project GET /projects/:id(.:format) projects#show
PUT /projects/:id(.:format) projects#update
DELETE /projects/:id(.:format) projects#destroy