ruby on rails - Deeply Nested Form Data not going into database, no errors -


i'm building multi-nested form in rails 3. i'm using formtastic_cocoon gem, don't think has bearing on issue.

i've got users, users have tasks, tasks have steps. nesting users>tasks>steps. can dynamically add , remove task fields user, , step fields tasks.

however, when submit form, user gets tasks, task>steps don't saved database.

rails isn't returning errors, nothing happens.

my models are

 class user < activerecord::base     acts_as_authentic      has_many :tasks         accepts_nested_attributes_for :tasks, :reject_if=> proc {|attributes| attributes[:entry].blank?}, :allow_destroy => true  end  class task < activerecord::base           attr_accessible :entry            belongs_to :user           has_many :steps          accepts_nested_attributes_for :steps, :reject_if=> proc {|attributes| attributes[:title].blank?}, :allow_destroy => true end  class step < activerecord::base         attr_accesible :title          belongs_to :task end  

in form.html.erb have

 <%= semantic_form_for @user %>     <%= form.inputs :username, :password %>     <div>       <% form.semantic_form_fields_for :tasks |builder| %>          <%= render 'task_fields', :f=>builder %>       <% end %>    <%= link_to_add_association 'add task', form, :tasks %>    </div> 

the _task_fields.html.erb looks this

  <div class="nested-fields">      <%= link_to_remove_association "remove task", f %>         <%= f.inputs :entry %>           <div>              <% f.semantic_form_fields_form :steps |builder| %>               <%= render 'step_fields' :f => builder %>              <% end %>            <%= link_to_add_association 'add step', f, :steps %>           </div> </div> 

lastly, _step_fields.html.erb page is

   <div class="nested-fields">    <%= link_to_remove_association "remove step", f %>     <%= f.inputs :title %>   </div> 

do see in log?:

warning: can't mass-assign protected attributes: steps_attributes 

if so, add task model:

attr_accessible :steps_attributes 

Comments

Popular posts from this blog

python - Scipy curvefit RuntimeError:Optimal parameters not found: Number of calls to function has reached maxfev = 1000 -

c# - How to add a new treeview at the selected node? -

java - netbeans "Please wait - classpath scanning in progress..." -