加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

ruby-on-rails – Rails 4升级 – ActionController :: UrlGener

发布时间:2020-12-16 19:23:46 所属栏目:百科 来源:网络整理
导读:我试图将我的应用程序从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/
我试图将我的应用程序从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的状态.

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读