Serialize array with strong_parameters

后端 未结 3 1371
感动是毒
感动是毒 2021-01-04 15:16

I am trying to save a array using the strong_parameters gem. But I am having issues with how the form is sending my array. The params look like this:

> pa         


        
相关标签:
3条回答
  • 2021-01-04 15:52

    Try using this:

    def circuit_params
      params.require(:circuit).permit(:title, :id, viewable_tasks:[], ... )
    end
    
    0 讨论(0)
  • 2021-01-04 15:54

    the serialized items must be in the end of the permit parameters. In my experience (and i dont know exactly why), you cannot input another unserialized item after a serialized one... try and let us know.

    0 讨论(0)
  • 2021-01-04 16:01

    I just had the same issue and this was the correct syntax:

    def circuit_params
      params.require(:circuit).permit(:title, :id, {:viewable_tasks => []}, ... )
    end
    
    0 讨论(0)
提交回复
热议问题