Here is a link to a great USD example:
USD Type-1
Bench has created a lot of great tutorials on all things rails, the first of which is here:
The quick answer to your rail question is best explained by the video, but I'll try to explain it the best I can.
-First place a button or (activation module)
-Place a rail in the desired direction directly adjacent to the button
-Link the button to the rail parent structure, not the desired direction rail
-Pressing the button should change the parent structure rails' orientation to that of the rail adjacent to the button
Hope that's not too confusing (check out the videos if it is!).