使用 HAML 而不是 ERB 会导致测试失败

And*_*ues 3 ruby haml ruby-on-rails erb ruby-on-rails-5

这看起来很基本,但我使用的是 Rails 5,我将所有视图都换成了 HAML 而不是 ERB。现在我的一项测试未能说出以下内容:

ActionController::UnknownFormat: ProductsController#index is missing  a template for this request format and variant.

request.formats: ["text/html"]
request.variant: []
    test/controllers/products_controller_test.rb:9:in `block in <class:ProductsControllerTest>'
Run Code Online (Sandbox Code Playgroud)

有什么地方可以更改默认值,还是我必须解决其他问题?我的路线很好,我可以访问索引页面没问题。

Mai*_*Ben 5

您需要haml安装,添加gem 'haml'到 Gemfile,然后bundle install在您的控制台中。