在 Rails 3.2.8 站点中,我收到以下错误:
Routing Error
No route matches {:controller=>"tasks", :action=>"complete", :list_id=>1, :id=>nil}
在我的路线文件中,我有以下内容:
resources :lists do
resources :tasks
end
match 'lists/:list_id/tasks/:id/complete' => 'tasks#complete', :as => :complete_task
在视图中:
<% @list.tasks.each do |task| %>
<li><%= task.description %> - <%= button_to "Complete",
complete_task_path(@list.id, task.id) %></li>
<% end %>
在做 rake 路线时:
complete_task /lists/:list_id/tasks/:id/complete(.:format) tasks#complete