What is the difference between using view templates in Rails as ‘.html.haml’ and as simply ‘.haml’?
For example,
show.html.haml
vs
show.haml
Are there any particular advantages of using one over the other? Or is one of them a standard practice? The same question goes for other types of templates as well, like ‘.erb’.
The format matters when you’re using Rails’ automatic responders. See http://api.rubyonrails.org/classes/ActionController/MimeResponds.html#method-i-respond_with.
So for example, with:
The app will render
app/views/cars/index.html.erbandapp/views/index.js.erbwhen viewinghttp://localhost:3000/carsandhttp://localhost:3000/cars.js, respectively.Additionally, this is an established convention in Rails-land, so it’s just a good idea to do this anyway, even if you’re not using the auto-responders.