Created
May 30, 2012 17:57
-
-
Save dmitryrck/2837959 to your computer and use it in GitHub Desktop.
This file contains 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 User < ActiveRecord::Base | |
has_many :things | |
end | |
class Thing < ActiveRecord::Base | |
validates :field_id, :uniqueness => { :scope => :user_id } | |
end | |
# Se vc for salvar um `user` com DENTRO DE UM NESTED FORM usando `things` ele vai gerar "falso positivo", ex.: | |
# | |
# things = { :user_id => 1, :other => true } | |
# things = { :user_id => 1, :other => false } | |
# | |
# Dentro de um nested gera falso positivo, pq antes de salvar o AR faz uma query para verificar, | |
# e depois salva todo de uma vez |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment