0

添加三个自定义成员路由后,在开发和生产环境中一切正常,但在测试环境中失败。

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却可用?谢谢...

4

1 回答 1

0

两周后,当我们回到这个问题时,它就消失了:似乎重新启动 rails server (thin) 和 guard 解决了它。

于 2013-01-07T11:26:21.047 回答