Unpermitted parameters nested attributes - rails

前端 未结 1 779
感情败类
感情败类 2021-01-28 12:56

I\'m trying to submit a form to 2 tables but somehow I got this syntax error unexpected \'\\n\' at this line joins: [\'sources\'], :landslide_id and

相关标签:
1条回答
  • 2021-01-28 13:29

    found unpermitted parameter: sources

    Based on your form, it looks like sources are inside a param called sources rather than sources_attributes. Edit your landslide_params, changing sources_attributes to sources.

    May I ask what set_landslide is trying to render, or correct me if I am wrong below? Placing joins on a new line causes the error. I am thinking you're trying to do something like:

    landslide = Landslide.find(params[:total_id])
    render json: landslide.to_json(:include => { :sources => { landslide_params[:sources] }})
    

    Which would give you a json with the landslide object and a sources array. The landslide id should be within the landslide object. This of course assumes that's what you were going for.

    0 讨论(0)
提交回复
热议问题