Weird JSON Javascript problem in Rails

前端 未结 2 688
被撕碎了的回忆
被撕碎了的回忆 2021-02-05 02:34

I\'m trying to get my JSON from my controller to my view. In my controller I am doing:

@nodes = Node.all
@json = @nodes.as_json(:only => [:ID, :Lat, :Lon]) 
<         


        
2条回答
  •  一生所求
    2021-02-05 02:48

    I think you need to put quotes around it, then you can ask jquery to parse the string into JSON.

提交回复
热议问题