Good question. i am not sure I am comfortable with my system either.
I usually try to find the posts that raise the rail above the deck. The stub posts stop the line from sliding along the rail.
I pass a loop under the rail and back up to the line from the boat. With the tail of the line, I pass it through the loop and then tie half hitches back on the line to the boat.
My idea is to make it solid enough to hold the boat in place yet easy enough to untie when leaving. The loop saves me from having to unwrap a lot of line around and under the rail.
In my experience, the rails are all rough-sawn. They leave splinters in my dock lines, and the dock lines tend to hang up on the rails.