Reputation: 83
This seems very basic, but I'm using Rails 5 and I swapped all of my views to HAML instead of ERB. Now one of my tests is failing saying the following:
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>'
Is there anywhere to change the default, or is there another issue I have to address? My routes are fine, and I can access the index page no problem.
Upvotes: 3
Views: 1531
Reputation: 1527
I saw the same issue and the solution for us was caused by adding the haml gem into development
group in the Gemfile
, make sure the haml related gems are in no group
Upvotes: 0
Reputation: 71
It means a missing template for the #index
method in controller.
Rails has a convention, it will search for this file in /views/
directory, the associated html.erb or haml file, following the name convention.
Upvotes: 0
Reputation: 839
You need haml
installed, add gem 'haml'
to the Gemfile, next bundle install
in your console.
Upvotes: 5
Reputation: 1204
Seems that you are missing the view file index.html.haml
in app/views/products
Upvotes: 1