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:
> params[:circuit]
=> {"title"=>"Some title", ..., "viewable_tasks"=>{"0"=>"woop", "1"=>"dee", ...}}
And my circuit_params
function looks like:
def circuit_params
params.require(:circuit).permit(:title, :id, viewable_tasks: { }, ... )
end
I can't seem to get the syntax to allow my params to work. What I get in my console is:
> circuit_params
=> {"title"=>"implement plug-and-play mindshare",
"viewable_tasks"=>{"0"=>nil, "1"=>nil, "2"=>nil}, ...
In my model I have:
class Circuit < ActiveRecord::Base
serialize :viewable_tasks, Array
...
end
I noticed that I can get it to work properly with attributes I call accepts_nested_attributes_for
on, so this may have something to do with it.
Thanks for any help
I just had the same issue and this was the correct syntax:
def circuit_params
params.require(:circuit).permit(:title, :id, {:viewable_tasks => []}, ... )
end
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With