I'm getting a Unpermitted parameters: latitude, longitude, address
error in the log when I try to accept nested attributes from a form. The exact params look like:
{
"widget"=> {
"owner"=>"100",
"name"=>"Widget Co",
"locations_attributes" => {
"0"=> {
"latitude"=>"51.4794259",
"longitude"=>"-0.1026201",
"address"=>"123 Fake Street"
}
}
},
"commit"=>"Create Supplier",
"action"=>"create",
"controller"=>"widgets"
}
A widget has_many
locations, and a location belongs_to
a widget. The params are set in the widgets_controller
which I thought would permit everything under "0", but doesn't seem to?
def widget_params
params.require(:widget).permit(:owner, :name, locations_attributes: [{"0" => []}])
end
Is there a working / better way to accept these params?
Thanks