I am using Rails 5.2.1 and ruby 2.5.0 for the development of my new project. I need to permit user params which has the following structure
{
"user_id": 1
"name": "John",
"pets": [
{
"id": 1,
"count": 5
},
{
"id": 2,
"count": 3
},
]
}
My User model has following lines
has_many :pets, dependent: :destroy
accepts_nested_attributes_for :pets
and in the controller
params.require(:user).permit(:user_id, :name, pets_attributes: %i(id, count))
But when I post the above json request it produces the following error
Unpermitted parameter: :pets
I couldn't find any solution. Please help. Thanks