开发者

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)

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜