i just learned how to grind a few weeks ago and started hitting rails shortly after
rule #1 LEAN FORWARD if you feel you are centered you are wrong, when you learn you have to leab foward so you don't fall back. you have a natural tendency to lean backward as your body is holding you back. thus your skis are up on edge and you will fall back. so think about leaning forward
rule #2 go fast (ish) if you go to slow your edges and stuff get caught on all the dings on the box so you want to come in with some speed so the rail/box feels smooth
when learning on a box just start by going straight on and every time you hit it just turn more and more until you are full 90. as matt walker says in jib jam, look at the end of the rail with your head but keep your shoulders in line with your body. pointing to the end of the rail can help also.
rule #3 - for rails make sure you go full 90 otherwise you will split you skis. once you can hit flat boxes with a full 90 hitting rails isn't so bad
thats pretty much it and again i started hitting rails in feb. so i can personally attest to these pointers