如何使用数组结果在轨道上渲染json ruby

时间:2015-01-12 23:36:57

标签: ruby-on-rails json

有:

def render
  begin
    array= [:orange => 1,:limon => 3]
  rescue Exception => e
    puts e
  end
end

如何在一个json中返回一个数组

1 个答案:

答案 0 :(得分:3)

def render
  begin
     array= [:orange => 1,:limon => 3]
     render :json => {:array => array},:callback => params[:callback]
  rescue Exception => e
     puts e
  end
end