Ruby on Rails: Sending javascript data to ruby controller

后端 未结 3 1574
野性不改
野性不改 2021-01-24 02:22

I would like to send a javascript array to be processed by a method in my controller. I think I am doing this way wrong. I am a total RoR, jquery, and ajax noobie. Here is what

3条回答
  •  醉话见心
    2021-01-24 02:57

    Agreed with Riateche's answer. You'll need to add some logic to the controller to respond correctly.

    Looking at your console output, you can see the json data in the parameters hash. You can simply access the values in your controller as such:

    params["125,0,\"\",\"Ph upt 1-2\""]
    params["125,0,\"\",\"Ph upt 1-2\""][","]
    

    You can just map it your activerecord model and save it.

提交回复
热议问题