Riding the rail (also called being "run out of town on a rail") was a punishment most prevalent in the United States in the 18th and 19th centuries in which an offender was made to straddle a fence rail held on the shoulders of two or more bearers. The victim was then paraded around town or taken to the city limits and dumped by the roadside.
Being ridden on a rail was typically a form of extrajudicial punishment administered by a mob, sometimes in connection with tarring and feathering, intended to show community displeasure with the offender so they either conformed their behavior to the mob's demands or left the community.
A story attributed to Abraham Lincoln has him quoting a victim of being ridden out of town on a rail as having said, "If it weren't for the honor of the thing, I'd just as soon it happened to someone else."
In the film O Brother, Where Art Thou?, Homer Stokes denounces the Soggy Bottom Boys as hostile to the social order, but the crowd is unimpressed and runs him out of town on a rail.