ruby-on-rails – Rails 4升级 – ActionController :: UrlGenerationError – 没有路由匹配

我试图将我的应用程序从Rails 3.2.x移植到Rails 4.0.4.所有的宝石都已经兼容,我正处于修复失败测试的阶段.

我有这种奇怪的测试失败.

我的routes.rb

resources :my_reports,only: [:index] do
  collection do
    get "/report/:filename",to: :show,prefix: "pri/excl/rep",as: :show
  end
end

我的规范已经在Rails 3.2.x中传递,现在在更新到4.0.4后失败了

describe MyReportsController do
  describe "#show" do
    def make_request
      get :show,prefix: 'some/place',filename: 'foo',format: 'doc'
    end

    it "makes a simple request" do
      make_request
    end
  end
end

我收到以下错误

Failure/Error: get :show,format: 'doc'
     ActionController::UrlGenerationError:
       No route matches {:action=>"show",:controller=>"my_reports",:filename=>"foo",:format=>"doc",:prefix=>"some/place"}

我被困在这一点,欢迎提示.我正在使用rspec和rspec-rails版本2.14.1.

解决方法

在测试中传递一个虚拟:id为我修复了问题虽然我不喜欢它,测试通过.
get :show,id: "",format: 'doc'

请参阅轨道版本here的状态.

相关文章

validates:conclusion,:presence=>true,:inclusion=>{...
一、redis集群搭建redis3.0以前,提供了Sentinel工具来监控各...
分享一下我老师大神的人工智能教程。零基础!通俗易懂!风趣...
上一篇博文 ruby传参之引用类型 里边定义了一个方法名 mo...
一编程与编程语言 什么是编程语言? 能够被计算机所识别的表...
Ruby类和对象Ruby是一种完美的面向对象编程语言。面向对象编...