I am trying to create a new entry in my database which contains an array images.
Using Product.new("title":"Hello World", "images":["a.jpg","b.jpg"]) I can create a new entry without problems. But when I try passing the parameters to my API, the array remains empty (all the other fields are filled).
The request I used:
curl -i -H "Accept: application/json" -H "Content-type: application/json" -X POST -d '{"title":"Hello World", "images":["a.jpg", "b.jpg"], "api_key":"API_KEY"}' http://localhost:3000/api/products
Parameters are passed using:
def product_params
params.require(:product).permit(:id, :title, :images)
end
A new database entry is then created using:
Product.new(product_params)
Any help is highly appreciated.