2015-01-12 79 views
2

軌JSON紅寶石有:如何渲染與陣列結果

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

如何在一個JSON

+0

返回數組你檢查什麼選擇? – Abecee

回答

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