2012-06-26 92 views
4

我試圖用繭加上formtastic繭寶石安裝/使用?

我的rails版本嵌套阿賈克斯形式

Rails 3.2.3 

我已經把創業板「破繭」 IM我的Gemfile並沒有捆綁安裝

然後在我的元素/ _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 %> 

與元素/ _experiment_fields.html.erb:

<div class='nested-fields'> 
    <%= f.input :exptype %> 
    <%= link_to_remove_association "remove experiment", f %> 
</div> 

此產生沒有錯誤,但不顯示該嵌套鏈接或形式

我然後添加到資產/ application.js中:

//= require cocoon 

和佈局/ application.html.erb

  <%= javascript_include_tag :cocoon %> 

此產生的錯誤:

 couldn't find file 'cocoon' 

我錯過了在繭安裝的東西? 任何人都可以幫忙嗎?

回答

1

在你layout/application.html.erb你應該只寫

= javascript_include_tag "application" 

,而不是:cocoon(即僅適用於舊的軌道3.0.x的)。 application.js將自動包含Cocoon JavaScript文件(資產管道)。

希望這會有所幫助。

10

剛剛在重新啓動我的Rails服務器之前向資產管道中添加// = require cocoon後出現此錯誤。顯然你可能已經重新啓動了你的rails服務器,但是爲了這個錯誤的其他人,請嘗試重新啓動rails。

+0

作爲一名rails初學者,我肯定會從現在開始不太經常遇到這種情況。 – schmijos