I have been having trouble with nested forms -- so I attempted to use the following gem: https://github.com/lailsonbm/awesome_nested_fields. Unfortunately the nested form (attitude) is not showing up in the task form -- I tried to follow the instructions exactly -- and I am hoping it is something dumb. I do not get any errors when the form is loaded.
task model
class Task < ActiveRecord::Base
has_many :attitudes
accepts_nested_attributes_for :attitudes, allow_destroy: true
attr_accessible :attitudes_attributes
end
attitude model
class Attitude < ActiveRecord::Base
belongs_to :task
accepts_nested_attributes_for :task
attr_accessible :tasks_attributes
end
task form
<%= form_for @task do |f| %>
<%= f.error_messages %>
<div class="items">
<%= f.nested_fields_for :attitudes do |f| %>
<fieldset class="item">
<%= f.label :name %>
<%= f.text_field :name %>
<a href="#" class="remove">remove</a>
<%= f.hidden_field :id %>
<%= f.hidden_field :_destroy %>
</fieldset>
<% end %>
</div>
<a href="#" class="add">Add Attitudes</a>
<% end %>
when I view the html source I see this
<script class="template item attitude" type="text/html">
<fieldset class="item">
<label for="task_attitudes_attributes_new_nested_item_name">Name</label>
<input id="task_attitudes_attributes_new_nested_item_name" name="task[attitudes_attributes][new_nested_item][name]" size="30" type="text" />
<a href="#" class="remove">remove</a>
<input id="task_attitudes_attributes_new_nested_item_id" name="task[attitudes_attributes][new_nested_item][id]" type="hidden" />
<input id="task_attitudes_attributes_new_nested_item__destroy" name="task[attitudes_attributes][new_nested_item][_destroy]" type="hidden" value="false" />
</fieldset>
</script>
task form header
<script src="/javascripts/jquery.js?1385786590" type="text/javascript"></script>
<script src="/javascripts/jquery_ujs.js?1385786591" type="text/javascript"></script>
<script src="/javascripts/jquery.nested-fields.js?1385787505" type="text/javascript"></script>
<script src="/javascripts/application.js?1385790193" type="text/javascript"></script>
<script src="/javascripts/bootstrap.js?1385522548" type="text/javascript"></script>
application.js
$(document).ready(function(e) {
$('FORM').nestedFields();
});