Q.getting rid of ants in flower beds
I have heard that cucumber slices are a deterrent. How about planting cucumbers?

In my research I did not see where cucumber plants repelled ants. It was always suggested to use cucumber slices or cucumber peels. I think the reason is that by slicing and peeling the cucumbers you release more of the juices and the pungency that deters the ants.
Here are some additional resources on eradicating ants:
https://www.gardeningknowhow.com/plant-problems/pests/insects/get-rid-of-ants.htm
https://www.gardeningknowhow.com/plant-problems/pests/insects/keeping-ants-off-flowers.htm