There is a pretty good account of how this works in Karl SchwedeKarl Schwede's paper:
MR2182775 (2006j:14003)
Karl Schwede, Gluing schemes and a scheme without closed points.
Recent progress in arithmetic and algebraic geometry, 157–172, Contemp. Math., 386, Amer. Math. Soc., Providence, RI, 2005
See also this paper:
MR2044495 (2005a:13016)
Ferrand, Daniel Conducteur, descente et pincement.
Bull. Soc. Math. France 131 (2003), no. 4, 553–585.