I have a controller:
class ItemsController < ApplicationController
respond_to :json def index items = Item.all respond_with(items) end
I am curling my_app/items.json and see a response with JSON object — just as expected. At this point I don’t have any views associated with controller, specifically I don’t have index.html.erb (.html).
Now if only I create an index.haml (for instance), with a simple %h1 Hello, world! line, requesting (again via curl) my_app/items.json returns an html string with
Hello, world!. Note that I didn’t alter the controller code — it just remains untouched.
I’m sure I’m missing something. Can anyone explain of what’s going on here?