ルーティング エラーが表示されます: [POST] "/students/1" に一致するルートがありません。詳細はこちら。
ビューコード:
<% @students.each do |student| %>
.
.
<td><%= link_to 'Show', student %></td>
<td><%= link_to 'Edit', edit_student_path(student) %></td>
<td><%= link_to 'Select Subjects', select_path(student) %></td> # error occurs here
私の学生のコントローラーでは:
def select
.
.
end
routes.rb: HomeSchool::Application.routes.draw do
resources :notes
resources :assignments
resources :subjects do
resources :assignments, :only => [:create, :index, :new]
end
resources :students
resources :resources
match "students/:id/select" => "students#select", :as => :select
root :to => 'students#index'
end
rake ルートからの出力は次のとおりです。
GET /students/:id/select(.:format) students/:id#select
notes GET /notes(.:format) notes#index
POST /notes(.:format) notes#create
new_note GET /notes/new(.:format) notes#new
edit_note GET /notes/:id/edit(.:format) notes#edit
note GET /notes/:id(.:format) notes#show
PUT /notes/:id(.:format) notes#update
DELETE /notes/:id(.:format) notes#destroy
assignments GET /assignments(.:format) assignments#index
POST /assignments(.:format) assignments#create
new_assignment GET /assignments/new(.:format) assignments#new
edit_assignment GET /assignments/:id/edit(.:format) assignments#edit
assignment GET /assignments/:id(.:format) assignments#show
PUT /assignments/:id(.:format) assignments#update
DELETE /assignments/:id(.:format) assignments#destroy
subject_assignments GET /subjects/:subject_id/assignments(.:format) assignments#index
POST /subjects/:subject_id/assignments(.:format) assignments#create
new_subject_assignment GET /subjects/:subject_id/assignments/new(.:format) assignments#new
subjects GET /subjects(.:format) subjects#index
POST /subjects(.:format) subjects#create
new_subject GET /subjects/new(.:format) subjects#new
edit_subject GET /subjects/:id/edit(.:format) subjects#edit
subject GET /subjects/:id(.:format) subjects#show
PUT /subjects/:id(.:format) subjects#update
DELETE /subjects/:id(.:format) subjects#destroy
students GET /students(.:format) students#index
POST /students(.:format) students#create
new_student GET /students/new(.:format) students#new
edit_student GET /students/:id/edit(.:format) students#edit
student GET /students/:id(.:format) students#show
PUT /students/:id(.:format) students#update
DELETE /students/:id(.:format) students#destroy
resources GET /resources(.:format) resources#index
POST /resources(.:format) resources#create
new_resource GET /resources/new(.:format) resources#new
edit_resource GET /resources/:id/edit(.:format) resources#edit
resource GET /resources/:id(.:format) resources#show
PUT /resources/:id(.:format) resources#update
DELETE /resources/:id(.:format) resources#destroy
select /students/:id/select(.:format) students#select
root / students#index
助言がありますか?レールでのルーティングがどのように機能するかを正確に把握するのに非常に苦労しており、それに関する論文をまだ見つけていませんが、選択したルートにメソッドがリストされていないことは少なくとも私の問題。
ありがとう、
ロン