This question answered my question partly. The author uses a similar json structure..
My Question: How to permit nested arrays in a nested object? I have a Contribution
model with has_many
Features
. I am trying to create GeoJSON polygons.
The coordinates
stays empty
This is the JSON I am sending
{
"contribution": {
"features_attributes": [
{
"geojson": {
"type": "Feature",
"properties": {},
"geometry": {
"type": "Polygon",
"coordinates": [
[
[
7.263336181640625,
52.07190953840937
],
[
7.263336181640625,
52.135173926548894
],
[
7.404785156249999,
52.135173926548894
],
[
7.404785156249999,
52.07190953840937
],
[
7.263336181640625,
52.07190953840937
]
]
]
}
}
}
],
"title": "324",
"description": "23"
}
}
Currently my permit code looks like this:
params.require(:contribution).permit(
:title,
:description,
features_attributes: [
{ geojson: [
:type,
{ geometry: [
:type,
#{ coordinates: [] } # this works for arrays like coordinates: [ 7.62, 51.96 ]
{ coordinates: [[]] }
]
}
]
}
]
)