Be moving fast enough so you can grind but not to fast.
Ride up paralell to your rail or ledge and Bunny hop.
Place you back peg on the rail then lower your front on.
Balance.
To get off just bunny hop off and land.