If the ball doesn't come back to the bed of the table, it's a foul. If the ball hits something on the rail (chalk, your arm, whatever) and then comes back to the bed of the table, it's a foul.
If the ball comes back to the bed without hitting anything, it's not a foul.