How can I debug/test a json response from my rails controller?
I have written a simple jquery response in my rails 3 controller, I just want to test to see the result this returns (not automated testing).
My code looks like this:
class AppointmentsController < ApplicationController
def jsonli开发者_高级运维st
@appointments = Appointment.find(:all)
render :json => @appointments
end
Can I access this from a URL like: http://localhost:3000/appointments/jsonlist?
When I try, I get this error:
Couldn't find Appointment with ID=jsonlist
The error you're getting does not appear to come from that action, it appears to be a conflict in your routes for whatever you have defined as your show
action. Try defining your route for jsonlist
before you define your route for show
.
to debug a json response from your controller
render json: JSON.pretty_generate(JSON.parse(@appointments.to_json))
精彩评论