I'm with Rails 4.
Various table have a relation to a "people" table. This table contain personal information like name, address etc... And a uniqueness identification number (it's not the ID, because it can be null).
validates :identification, :uniqueness => true, :allow_blank => true
The people model is alway registred like a nested attributes. For example, a store can have a responsible person. So when I do the
@store = Store.new(store_params)
or
@store.update(store_params)
I want the associated person was created or just associated and updated depending if the identification number exist or not.
Actualy, if a put a existing Identification, activerecord try to create a new one a send a "already in use" error, because the uniqueness validator.
what would be the right way to do that?
Thanks.