The ruling applies to all public schools in California and is a victory for two teachers who claimed that district policies violated their constitutional free speech and religious rights.