(CNN) A federal judge has ruled in favor of the three sex offenders who sued a Georgia sheriff after his deputies put signs in the men's yards last year warning trick-or-treaters not to visit on Halloween.

The three men sued on behalf of all registered sex offenders in Butts County after finding out the sheriff's office was planning on putting the same signs this year, according to the ruling.

"The question the Court must answer is not whether (Butts County Sheriff Gary Long's) plan is wise or moral, or whether it makes penological sense. Rather, the question is whether Sheriff Long's plan runs afoul of the First Amendment of the United States Constitution. It does," the ruling says.

Georgia displays all registered sex offenders' names, photos and addresses in a public online directory. But the statute "does not require or authorize sheriffs to post signs in front of sex offenders' homes," the ruling states.

Judge Marc Treadwell granted a preliminary injunction for the plaintiffs and ruled that sheriff Long and his employees can't place the signs during this year's Halloween season on the three men's yards --- but didn't broaden the injunction to all sex offenders in the county.

Read More