控制器测试错误消息:"ActionView::Template::Error: The asset " MyString " is not present in the asset pipeline"



这是失败的测试代码:

test "should get index" do
get products_url
assert_response :success
end

错误信息为 ActionView::模板::错误:资产管道中不存在资产"MyString"。

跆拳道?

遇到了同样的问题,但找到了一个简单的解决方案。 首先我修复了/test/fixtures/products.yml

one:
title: MyString
description: MyText
image_url: lorem.jpg
price: 9.99
two:
title: MyString
description: MyText
image_url: lorem.jpg
price: 9.99

最后,我实际上在我的资产/图像中添加了一个名为"lorem.jpg"的图像。我发现这很令人困惑,因为他们在书中根本没有提到这一点,但希望这个小指针能让你回到正轨。

您必须确保灯具中的图像存在。 看这里

相关内容

最新更新