pedroooo
pedroooo

Reputation: 583

How Render json ruby on rails with array result

Have:

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

how to return a array in one json

Upvotes: 2

Views: 1403

Answers (1)

Luis
Luis

Reputation: 545

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

Upvotes: 3

Related Questions