添加三个自定义成员路由后,在开发和生产环境中一切正常,但在测试环境中失败。
在config/routes.rb
中,我们的自定义成员路由是复制、下载和中止:
resources :kw_researches do
member do
get 'copy'
get 'download'
put 'abort'
end
end
运行rake routes
显示成员路线都很好而且花花公子(不足为奇,因为它们实际上在生产和开发中工作):
$ rake routes
copy_kw_research GET /kw_researches/:id/copy(.:format) kw_researches#copy
download_kw_research GET /kw_researches/:id/download(.:format) kw_researches#download
abort_kw_research PUT /kw_researches/:id/abort(.:format) kw_researches#abort
kw_researches GET /kw_researches(.:format) kw_researches#index
POST /kw_researches(.:format) kw_researches#create
new_kw_research GET /kw_researches/new(.:format) kw_researches#new
edit_kw_research GET /kw_researches/:id/edit(.:format) kw_researches#edit
kw_research GET /kw_researches/:id(.:format) kw_researches#show
PUT /kw_researches/:id(.:format) kw_researches#update
DELETE /kw_researches/:id(.:format) kw_researches#destroy
但是两者的测试都失败了,./spec/views/kw_researches/index.html.erb_spec.rb
并./spec/integration/kw_research_index_page_spec.rb
出现以下错误:
10) KwResearch index page KwResearch has all relevant actions
Failure/Error: visit kw_researches_path
ActionView::Template::Error:
undefined method `copy_kw_research_path' for #<#<Class:0x007faab8c9a238>:0x007faab717fd40>
为什么copy_kw_research_path
不可用,而它的好(标准助手)朋友edit_kw_research_path
却可用?谢谢...