** Benefits of haml **
--No need for closing tags or ``` <% end%>` ``, just put it in a concise manner. ――If the indentation is not correct, an error will occur, so even if you don't like it, apply it neatly.
In addition to the above merits, there are many opportunities to use it in the field, so after studying, I introduced haml to Rails. At that time, the error `` `missing a template``` occurred and I was a little troubled, so I will leave it here as a memo. If you are looking at this page, I think that many people have already installed haml, so please jump to the solution at the bottom. For those who don't, I will also explain how to install haml.
(environment)
Gemfile
gem 'haml-rails'
$ docker-compose exec service name bundle
Since Docker is used for the development environment, `docker-compose exec service name`
is added.
This completes the introduction of haml.
$ docker-compose exec service name rails haml:erb2haml
This is all it takes to convert an erb file to haml.
ActionController::UnknownFormat (PostsController#index is missing a template
for this request format and variant.
request.formats: ["text/html"]
request.variant: []
NOTE! For XHR/Ajax or API requests, this action would normally respond with
204 No Content: an empty white screen. Since you're loading it in a web
browser, we assume that you expected to actually render a template, not
nothing, so we're showing an error to be extra-clear. If you expect 204 No
Content, carry on. That's what you'll get from an XHR or API request. Give
it a shot.)
When I accessed localhost, I got the above error and the view disappeared.
The solution is just to restart the server. (`` `rails s```) In my case, I used docker for the development environment, so I restarted the container.
$ docker-compose restart
I think this will solve it. *** I was about to enter the labyrinth without even thinking of restarting when the field of view narrowed. *** *** I want to be careful to have a wide field of view when an error occurs.