Solvent effects on polymer gels: A statistical-mechanical model