In Ruby on Rails, how to render JSON?
I tried the following to respond to AJAX and it works (in HAML):
- response.content_type = "application/json"
= render :text => array_data.to_json
but
- resp开发者_如何学运维onse.content_type = "application/json"
= render :json => array_data.to_json
doesn't work. I thought I could use
= render :text => array_data.to_json
instead of the first 2 lines at the top?
= render :json => @object
(u don't need to use .to_json method)
精彩评论