Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

cocoon gem install / usage?

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?

like image 708
Matoeil Avatar asked Dec 16 '22 22:12

Matoeil


1 Answers

I just got this error after adding //= require cocoon to the asset pipeline, before restarting my rails server. Obviously you have probably restarted your rails server at this point, but for the sake of anyone else with this error, try restarting rails.

like image 98
Ben Fischer Avatar answered Dec 21 '22 23:12

Ben Fischer