Skip to content

Instantly share code, notes, and snippets.

@rrmartins
Created May 29, 2012 16:01
Show Gist options
  • Select an option

  • Save rrmartins/2829223 to your computer and use it in GitHub Desktop.

Select an option

Save rrmartins/2829223 to your computer and use it in GitHub Desktop.
Validacao
class Noticia << ....
validate :texto_inicio_igual
def texto_inicio_igual
noticias = Noticia.all
i = 0
noticias.each do |noticia|
if noticia.texto.split(" ")[0] === self.texto.split("")[0]
i += 1
end
end
if i > 0
return false
else
return true
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment