Ruby on Rails Wednesday, December 28, 2011

I have a controller:


  class ItemsController < ApplicationController
    respond_to :json

    def index
      items = Item.all

      respond_with(items)
    end
  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 <h1>Hello, world!</h1>. 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?

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To view this discussion on the web visit https://groups.google.com/d/msg/rubyonrails-talk/-/G-BUP_w7OasJ.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.

No comments:

Post a Comment