i am trying to use cocoon for nested ajax form coupled with formtastic
my rails version
Rails 3.2.3
i have put gem "cocoon" im my gemfile and did a bundle install
then in my elements/_form.html.erb:
<%= semantic_form_for @element do |f| %>
<%= f.inputs do %>
<%= f.input :projects, :label_method => :projectname%>
<%= f.semantic_fields_for :experiments do |exp| %>
<% render 'experiment_fields', :f => exp %>
<%= link_to_add_association "Add experiment", f, :experiments%>
<%end%>
<% end %>
<%= f.actions :submit, :cancel %>
<% end %>
with elements/_experiment_fields.html.erb :
<div class='nested-fields'>
<%= f.input :exptype %>
<%= link_to_remove_association "remove experiment", f %>
</div>
this generate no error but do not display the nested link or form
i then added to assets/application.js:
//= require cocoon
and to layout/application.html.erb
<%= javascript_include_tag :cocoon %>
this generate the error :
couldn't find file 'cocoon'
did i miss something in cocoon installation ? could anyone help?
In your layout/application.html.erb
you should just write
= javascript_include_tag "application"
and not the :cocoon
(that is only for older rails 3.0.x). The application.js
will contain the cocoon javascript files automatically (asset pipeline).
Hope this helps.