class Shop < ActiveRecord::Base
has_many :documents
validates :name, :presence => true
accepts_nested_attributes_for :documents
class Document < ActiveRecord::Base
belongs_to :shop
validates :reference_number, :presence => true
The partial _form for shop is:
- @shop.documents.build
= simple_form_for(@shop) do |shop_f|
= render 'shared/error_messages', :object => @shop
= render :partial => 'documents/form', :locals => { :form => shop_f }
= field_set_tag t('shop') do
.inputs
= shop_f.input :role_number
= shop_f.input :role_date
= shop_f.input :name
the partial _form for document is:
= form.simple_fields_for :documents do |document_f|
= field_set_tag t('document') do
.inputs
= document_f.input :reference_number
When I submit the form with no values in shop name or document
reference_number I have the errors messages and it is correct but in
the page I have the shop form with two document form.
Why the two document forms?
Sorry for my bad english hope my problem is clear.