Created
May 29, 2012 16:01
-
-
Save rrmartins/2829223 to your computer and use it in GitHub Desktop.
Validacao
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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