Rails converts empty arrays into nils in params of the request

后端 未结 6 1781
闹比i
闹比i 2021-02-01 12:20

I have a Backbone model in my app which is not a typical flat object, it\'s a large nested object and we store the nested parts in TEXT columns in a MySQL database.

I wa

6条回答
  •  梦毁少年i
    2021-02-01 12:35

    I ran into similar issue.

    Fixed it by sending empty string as part of the array.

    So ideally your params should like

    {
      name: "foo",
      surname: "bar",
      nested_json: {
        complicated: [""]
      }
    }
    

    So instead of sending empty array I always pass ("") in my request to bypass the deep munging process.

提交回复
热议问题