my ruby on rails 3.0.3 app display an empty address form when showing the cart to a customer.
The addresse module ask the presence of all fields :
validates :nom,:prenom,:adresse,:code_postal,:ville,:email, :presence => true
If I validate an empty form it works despite validate condition. I complete the forms, go to next page and comes back to the now populated creation form. Now if i remove a field the valiates is taken into account.
Here is my empty address creation code for the nested form in the show action :
if (@cartshowed.adresse_client.nil?)
@cartshowed.build_adresse_client
end
I guess that when usind the empty address validation is ignored, but as soon as i validate data for an already valid adress it works.
How can i have validation working when i create the address, and not only for edition ?
PS : The edition/creation is done on the same page through the same controllers. Edition was not intended to exist but it works.
EDIT : After several try i think my problem is that creating adresse through nested forms completly overiddes validates field in address. How can i kee validates restriction in a nested form?