There is a pretty good account of how this works in [Karl Schwede][1]'s [paper][2]:

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][3]:

MR2044495 (2005a:13016) 

Ferrand, Daniel
*Conducteur, descente et pincement.*

Bull. Soc. Math. France 131 (2003), no. 4, 553–585. 


  [1]: https://mathoverflow.net/users/3521/karl-schwede
  [2]: http://www.ams.org/mathscinet/search/publdoc.html?pg1=IID&s1=773868&vfpref=html&r=11&mx-pid=2182775
  [3]: http://www.ams.org/mathscinet/search/publdoc.html?r=1&pg1=CNO&s1=2044495&loc=fromrevtext