If there's no permanent ladder or stairs leading to the attic, you may be able to simply lay the cable across the rafters.
"Where this space is not accessible by permanent stairs or ladders, protection shall only be required within 1.8 m (6 ft) of the nearest edge of the scuttle hole or attic entrance.".
National Electrical Code
Chapter 3 Wiring Methods and Materials
334.23 In Accessible Attics. The installation of cable in accessible attics or roof spaces shall also comply with 320.23.
Article 320 Armored Cable: Type AC
320.23 In Accessible Attics. Type AC cables in accessible attics or roof spaces shall be installed as specified in 320.23(A) and (B).
(A) Where Run Across the Top of Floor Joists. Where run across the top of floor joists, or within 2.1 m (7 ft) of floor or floor joists across the face of rafters or studding, in attics and roof spaces that are accessible, the cable shall be protected by substantial guard strips that are at least as high as the cable. Where this space is not accessible by permanent stairs or ladders, protection shall only be required within 1.8 m (6 ft) of the nearest edge of the scuttle hole or attic entrance.
(B) Cable Installed Parallel to Framing Members. Where the cable is installed parallel to the sides of rafters, studs, or floor joists, neither guard strips nor running boards shall be required, and the installation shall also comply with 300.4(D).
Article 300.4(D) says that if you do attach the cable to the ridge beam, you'll have to keep it 1 1/4" away from either edge.
Article 300 Wiring Methods
300.4 Protection Against Physical Damage. Where subject
to physical damage, conductors shall be protected.
(D) Cables and Raceways Parallel to Framing Members
and Furring Strips. In both exposed and concealed
locations, where a cable- or raceway-type wiring method is
installed parallel to framing members, such as joists,
rafters, or studs, or is installed parallel to furring strips, the
cable or raceway shall be installed and supported so that the
nearest outside surface of the cable or raceway is not less
than 32 mm (1 1⁄4 in.) from the nearest edge of the framing
member or furring strips where nails or screws are likely to
penetrate. Where this distance cannot be maintained, the
cable or raceway shall be protected from penetration by
nails or screws by a steel plate, sleeve, or equivalent at least
1.6 mm (1⁄16 in.) thick.