views:

12

answers:

0

I have this models

class Store < ActiveRecord::Base

has_many :person , :class_name =>"person"  
accepts_nested_attributes_for :person  

end

class Person < ActiveRecord::Base

 has_many :addresses,  
 :as => :addressable,  
 :dependent => :destroy,  
 :validate => false  

 accepts_nested_attributes_for :addresses   

end

class Address < ActiveRecord::Base

 belongs_to :addressable, :polymorphic => true  

end

How I access the nested attribute by Store.new

this my views

- form_for(@store, :html=>{:method=>:post},:url=>{:action=>"create", :plano=>"#{params[:plano]}"}) do |f|

 = f.text_field :name
    - @store.person.build if @store.person.empty?      
    - f.fields_for :person, f do |p|
        = p.label 'Pessoa de Contato'

** NOW CAME THE PROBLEM

        - @store.person.build.addresses.build if @store.person.build.addresses.nil?
        - p.fields_for :addresses, @addresses do |addr|
          = addr.label 'Titulo de endereço'

I don't get to make the nested attribute of model person works with the first model. My server only freeze the service. I don't receive any error in log or in browser