jeudi 17 décembre 2015

Create json object with loop ruby on rails

I want to create a JSON object out of ruby object on view file like

:coffeescript
 files = {}
  - @filelist.each do |f|
    = files[f[0]] = f[1]
  console.log(files)

it gives me an "Unexpected logic" error

following is array declared in controller

@filelist = Array.new
@filelist.push(['ref','count'])
@filelist.push(['input1','count'])
@filelist.push(['input2','count'])

Aucun commentaire:

Enregistrer un commentaire