this is the json received as parameters from external angular webapp:
{
"provincia": {
"id": 1,
"name": "Province"
},
"username": "tester",
"direccion": "new avenue 100",
"email": "[email protected]"
}
this is my controller
def create
@seller = Seller.new(seller_params)
if @seller.save
render json: @seller, status: :created, location: @seller
else
puts @seller.errors.full_messages
render json: @seller.errors, status: :unprocessable_entity
end
end
this is seller_params
def seller_params
params.require(:seller).permit(:username, :direccion, :email, :provincia_id)
end
models: Seller belongs_to Provincia
server console output error full message
Provincia must exist
Which modification in the Rails API should I do to make it work, and save the new seller? thanks in advance.