On Jan 5, 5:10 pm, Milo Thurston <[email protected]> wrote:
> I've found a strange (to me) response from rails if I try to render
> output as json, whereas xml is fine. From the logs. For example, here
> are the logs for a simple query (from the browser) to list all "jobs":
>
Probably because the browser has indicated (via the Accept header)
that text/xml is fine, but that json isn't. Can you inspect the
headers to see whether or not this is the case?

Fred
> Started GET "/jobs.json" for 127.0.0.1 at 2011-01-05 16:44:45 +0000
>   Processing by JobsController#index as JSON
> Completed 406 Not Acceptable in 11ms
>
> Started GET "/jobs.xml" for 127.0.0.1 at 2011-01-05 16:48:11 +0000
>   Processing by JobsController#index as XML
> Completed 200 OK in 13ms (Views: 1.9ms)
>
> The code being called is much the same:
>
>  def index
>     @jobs = Job.all
>     respond_to do |format|
>       format.html # index.html.erb
>       format.xml  { render :xml => @jobs }
>       format.json  { render :json => @jobs }
>     end
>   end
>
> Is this some dreadful misunderstanding on my part as to how rails 3
> works, or is something else at work here?
>
> --
> Posted viahttp://www.ruby-forum.com/.

-- 
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.

Reply via email to