Observation:
When you rename the index.haml file to index.html.haml, it will work as expected
(at least it works here and I could reproduce your problem).
For json, the default built-in handler for the json format is used.
For html, the index.html.haml template is used
Speculation:
I presume that Rails first checks if for json, a file with any of the standard
handlers is present (from the error message below, that would be :erb,
:builder, :coffee, :haml).
Missing template orders/index, application/index with {:handlers=>[:erb, :builder, :coffee, :haml], :formats=>[:json], :locale=>[:en, :en]}.
Now if it sees a file ending in .html.haml it is clear that this is a html file
(and not an XML or a JSON file) and not use that file as a template.
But for a file index.haml , I presume Rails accepts this also for rendering json,
even without the .json.haml ending ...
So, I created 2 additional files:
peterv@e6500:~/b/app/views/orders$ vim index.json.haml
peterv@e6500:~/b/app/views/orders$ rm index.json.haml
peterv@e6500:~/b/app/views/orders$ vim index.haml
peterv@e6500:~/b/app/views/orders$ rm index.haml
And the picking order is clear:
* highest priority: index.json.haml
* lesser priority: index.haml
* default: built-in json renderer
* never used: index.html.haml
HTH,
Peter