Gates are available in four standard lengths or sizes — 22″, 27″, 32″, and 37″.
Measure the opening between the guardrails.  The gate size should be equal to or greater than the opening.  This will insure that when the gate is closed, it will contact the vertical post of the opposite guardrail.  Thus if the opening is 25″, a 27″ gate would be needed.