我遇到问题:启动服务器后出现此错误: 未定义的局部变量或方法`prepodavatels_stats_path'用于#<#:0x0000000461ec58>我在这篇文章中提出了rake路线。
以下一行出错
<li><%= link_to "", prepodavatels_stats_path %><li>
的routes.rb
resources :prepodavatels do
collection do
get 'stats'
end
resources :predmets
resources :ppdatas
end
rake routes
Prefix Verb URI Pattern Controller#Action
groups GET /groups(.:format) groups#index
POST /groups(.:format) groups#create
new_group GET /groups/new(.:format) groups#new
edit_group GET /groups/:id/edit(.:format) groups#edit
group GET /groups/:id(.:format) groups#show
PATCH /groups/:id(.:format) groups#update
PUT /groups/:id(.:format) groups#update
DELETE /groups/:id(.:format) groups#destroy
students_index2 GET /students/index2(.:format) students#index2
students_index3 GET /students/index3(.:format) students#index3
students_index4 GET /students/index4(.:format) students#index4
students_index5 GET /students/index5(.:format) students#index5
students_index6 GET /students/index6(.:format) students#index6
stats_students GET /students/stats(.:format) students#stats
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
PATCH /students/:id(.:format) students#update
PUT /students/:id(.:format) students#update
DELETE /students/:id(.:format) students#destroy
stats_prepodavatels GET /prepodavatels/stats(.:format) prepodavatels#stats
predmets GET /prepodavatels/predmets(.:format) predmets#index
POST /prepodavatels/predmets(.:format) predmets#create
new_predmet GET /prepodavatels/predmets/new(.:format) predmets#new
edit_predmet GET /prepodavatels/predmets/:id/edit(.:format) predmets#edit
predmet GET /prepodavatels/predmets/:id(.:format) predmets#show
PATCH /prepodavatels/predmets/:id(.:format) predmets#update
PUT /prepodavatels/predmets/:id(.:format) predmets#update
DELETE /prepodavatels/predmets/:id(.:format) predmets#destroy
ppdatas GET /prepodavatels/ppdatas(.:format) ppdatas#index
POST /prepodavatels/ppdatas(.:format) ppdatas#create
new_ppdata GET /prepodavatels/ppdatas/new(.:format) ppdatas#new
edit_ppdata GET /prepodavatels/ppdatas/:id/edit(.:format) ppdatas#edit
ppdata GET /prepodavatels/ppdatas/:id(.:format) ppdatas#show
PATCH /prepodavatels/ppdatas/:id(.:format) ppdatas#update
PUT /prepodavatels/ppdatas/:id(.:format) ppdatas#update
DELETE /prepodavatels/ppdatas/:id(.:format) ppdatas#destroy
prepodavatels GET /prepodavatels(.:format) prepodavatels#index
POST /prepodavatels(.:format) prepodavatels#create
new_prepodavatel GET /prepodavatels/new(.:format) prepodavatels#new
edit_prepodavatel GET /prepodavatels/:id/edit(.:format) prepodavatels#edit
prepodavatel GET /prepodavatels/:id(.:format) prepodavatels#show
PATCH /prepodavatels/:id(.:format) prepodavatels#update
PUT /prepodavatels/:id(.:format) prepodavatels#update
DELETE /prepodavatels/:id(.:format) prepodavatels#destroy
admin GET /admin(.:format) admin#index
admin_index GET /admin/index(.:format) admin#index
ppdatas_index GET /ppdatas/index(.:format) ppdatas#index
ppdatas_index2 GET /ppdatas/index2(.:format) ppdatas#index2
index2_year_courses PATCH /year_courses/index2(.:format) year_courses#index2
year_courses GET /year_courses(.:format) year_courses#index
POST /year_courses(.:format) year_courses#create
new_year_course GET /year_courses/new(.:format) year_courses#new
edit_year_course GET /year_courses/:id/edit(.:format) year_courses#edit
year_course GET /year_courses/:id(.:format) year_courses#show
PATCH /year_courses/:id(.:format) year_courses#update
PUT /year_courses/:id(.:format) year_courses#update
DELETE /year_courses/:id(.:format) year_courses#destroy
group_new GET /groups/:group_id/new(.:format) groups#new
group_show GET /groups/:group_id/show(.:format) groups#show
PATCH /groups/index(.:format) groups#index
PATCH /groups/new(.:format) groups#new
_form_groups PATCH /groups/_form(.:format) groups#_form
PATCH /groups/show(.:format) groups#show
GET /groups(.:format) groups#index
POST /groups(.:format) groups#create
GET /groups/new(.:format) groups#new
GET /groups/:id/edit(.:format) groups#edit
GET /groups/:id(.:format) groups#show
PATCH /groups/:id(.:format) groups#update
PUT /groups/:id(.:format) groups#update
DELETE /groups/:id(.:format) groups#destroy
GET /students/index2(.:format) students#index2
GET /students/index3(.:format) students#index3
GET /students/index4(.:format) students#index4
GET /students/index5(.:format) students#index5
GET /students/index6(.:format) students#index6
students_stats GET /students/stats(.:format) students#stats
login GET /login(.:format) sessions#new
POST /login(.:format) sessions#create
logout DELETE /logout(.:format) sessions#destroy
ppdatas3 GET /ppdatas/index3(.:format) ppdatas#index3
ppdatas2 GET /ppdatas/index2(.:format) ppdatas#index2
sessions_new GET /sessions/new(.:format) sessions#new
sessions_create GET /sessions/create(.:format) sessions#create
sessions_destroy GET /sessions/destroy(.:format) sessions#destroy
users GET /users(.:format) users#index
POST /users(.:format) users#create
new_user GET /users/new(.:format) users#new
edit_user GET /users/:id/edit(.:format) users#edit
user GET /users/:id(.:format) users#show
PATCH /users/:id(.:format) users#update
PUT /users/:id(.:format) users#update
DELETE /users/:id(.:format) users#destroy
GET /ppdatas(.:format) ppdatas#index
POST /ppdatas(.:format) ppdatas#create
GET /ppdatas/new(.:format) ppdatas#new
GET /ppdatas/:id/edit(.:format) ppdatas#edit
GET /ppdatas/:id(.:format) ppdatas#show
PATCH /ppdatas/:id(.:format) ppdatas#update
PUT /ppdatas/:id(.:format) ppdatas#update
DELETE /ppdatas/:id(.:format) ppdatas#destroy
GET /students(.:format) students#index
POST /students(.:format) students#create
GET /students/new(.:format) students#new
GET /students/:id/edit(.:format) students#edit
GET /students/:id(.:format) students#show
PATCH /students/:id(.:format) students#update
PUT /students/:id(.:format) students#update
DELETE /students/:id(.:format) students#destroy
course_years GET /courses/:course_id/years(.:format) years#index
POST /courses/:course_id/years(.:format) years#create
new_course_year GET /courses/:course_id/years/new(.:format) years#new
edit_course_year GET /courses/:course_id/years/:id/edit(.:format) years#edit
course_year GET /courses/:course_id/years/:id(.:format) years#show
PATCH /courses/:course_id/years/:id(.:format) years#update
PUT /courses/:course_id/years/:id(.:format) years#update
DELETE /courses/:course_id/years/:id(.:format) years#destroy
course_courses GET /courses/:course_id/courses(.:format) courses#index
POST /courses/:course_id/courses(.:format) courses#create
new_course_course GET /courses/:course_id/courses/new(.:format) courses#new
edit_course_course GET /courses/:course_id/courses/:id/edit(.:format) courses#edit
course_course GET /courses/:course_id/courses/:id(.:format) courses#show
PATCH /courses/:course_id/courses/:id(.:format) courses#update
PUT /courses/:course_id/courses/:id(.:format) courses#update
DELETE /courses/:course_id/courses/:id(.:format) courses#destroy
courses GET /courses(.:format) courses#index
POST /courses(.:format) courses#create
new_course GET /courses/new(.:format) courses#new
edit_course GET /courses/:id/edit(.:format) courses#edit
course GET /courses/:id(.:format) courses#show
PATCH /courses/:id(.:format) courses#update
PUT /courses/:id(.:format) courses#update
DELETE /courses/:id(.:format) courses#destroy
GET /predmets(.:format) predmets#index
POST /predmets(.:format) predmets#create
GET /predmets/new(.:format) predmets#new
GET /predmets/:id/edit(.:format) predmets#edit
GET /predmets/:id(.:format) predmets#show
PATCH /predmets/:id(.:format) predmets#update
PUT /predmets/:id(.:format) predmets#update
DELETE /predmets/:id(.:format) predmets#destroy
years GET /years(.:format) years#index
POST /years(.:format) years#create
new_year GET /years/new(.:format) years#new
edit_year GET /years/:id/edit(.:format) years#edit
year GET /years/:id(.:format) years#show
PATCH /years/:id(.:format) years#update
PUT /years/:id(.:format) years#update
DELETE /years/:id(.:format) years#destroy
答案 0 :(得分:1)
尝试
<li><%= link_to stats_prepodavatels_path %><li>
这有用吗?