问题
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
- response.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?
回答1:
= render :json => @object
(u don't need to use .to_json method)
来源:https://stackoverflow.com/questions/3367246/in-ruby-on-rails-how-to-render-json