I used to have a lot of luck getting my cactus to flower by placing the plant on a window sill that received a lot of bright light (full sun) in winter, but it was a window sill that was pretty cold in the winter, 60 F. or below, but not freezing. I remember the window used to get frosty inside (that’s how cool it was). The cactus needed that “cold”, resting period in winter. Also, water it minimally in the winter, only once a month, just to keep it from shrivelling. In spring, as the temperature warms up, water it every week, and give it a shot of weak fertilizer. Your cactus should flower.
It depends on the kind of cactus you have too. Some flower more readily than others. You can find the easily flowering kinds in a cactus book. Some have to mature first before they flower (like after 10 years). Others flower when they’re very young (2 or 3 years old).
I believe rat tail cacti flower more readily than others. It’s beautiful in flower. I used to see one at my barber’s in flower.