I use that grip stuff (not sure what it's called) that you use in drawers to keep them from slipping. You can attach it with a drop of glue on the ruler.
I have also used those window grippy things that you get a Harbor Freight and put them onto the ruler.
Just saying ............
Blessings. Ellie