ActionView :: Template :: Error:无法将图像解析为URL:nil:NilClass的未定义方法'[]'

问题描述 投票:0回答:1

使用:Ruby 2.4.0p0Rails 5.2.3在运行测试用例时:有错误:

我的测试用例就像:

require 'test_helper'

class SubscriptionsControllerTest < ActionDispatch::IntegrationTest

  test "Can reach to index " do
    get subscriptions_url
    assert_response :success
  end

结束

错误:

SubscriptionsControllerTest#test_Can_reach_to_index_:
ActionView::Template::Error: Can't resolve image into URL: undefined method `[]' for nil:NilClass
    app/views/subscriptions/index.html.erb:43:in `_app_views_subscriptions_index_html_erb__900758959545617488_70234463713200'
    test/controllers/subscriptions_controller_test.rb:6:in `block in <class:SubscriptionsControllerTest>'

但是当手动打开ui时,图像会正确加载。你能建议出什么问题吗?视图中的image_tag位于第43行。

 <%= image_tag 'tukacad_1.png', alt: '', class: "img-responsive" %>
html ruby-on-rails-3 ruby-on-rails-5 ruby-2.4
1个回答
0
投票
@ vidur您可以在控制器和视图中包含代码吗?我试图在您的消息中发表评论,但我还没有足够的声誉。
© www.soinside.com 2019 - 2024. All rights reserved.