The RAT automatically deploys in case of an electrical emergency (losing both AC buses).
It has a generator that generates 15kva for the essential buses, one of them connected to an electric hydraulic pump for the 3rd hydraulic system, for primary flight control tasks. The RAT takes 8 seconds to start generating power, and in the meantime the 2 primary batteries supply electrical power.
If the RAT fails to deploy, the flight crew can manually deploy it.
If all of these fails, including your engine generators, you have a FBW backup battery, that the manufacturer states lasts at least 15 minutes for the elevator and rudder actuators. Note that the ailerons are not FBW, and use conventional cables to command the PCUs.
That's basically how it works.