我試圖切換站點與formtastic使用nested_form寶石組合,我已經使用,但我發現了一個奇怪的錯誤。在開發過程中一切正常,測試通過。此錯誤僅在生產中發生。爲什麼semantic_nested_form_for方法在我的生產環境中缺少什麼?
訪問在使用semantic_nested_form_for
的網頁導致以下錯誤:
ActionView::Template::Error (undefined method `semantic_nested_form_for' for #<#<Class:0x0000000524cca0>:0x00000004e46a70>):
1: <%= semantic_nested_form_for(@volume) do |f| %>
2: <%= f.inputs do %>
3: <%= f.input :number, :label => 'Volume #', :input_html => {:style => 'width:100px;', :autofocus => true}, :hint => raw('Choose the volume number.') %>
4: <% end %>
app/views/volumes/_form.html.erb:1:in `_app_views_volumes__form_html_erb__2632693694855646779_43838320'
app/views/volumes/new.html.erb:3:in `_app_views_volumes_new_html_erb___2327298489284463705_41053660'
寶石是我的Gemfile,似乎正確安裝:
[~/application/current]$ bundle show nested_form
/home/deployer/application/shared/bundle/ruby/1.9.1/gems/nested_form-0.3.1
我甚至可以成功調用semantic_nested_form_for
在生產控制檯上:
[~/application/current]$ rails c production
Loading production environment (Rails 3.2.12)
irb(main):001:0> helper.semantic_nested_form_for(Volume.new, url: '/volumes' do |f|
irb(main):002:2* f.inputs
irb(main):003:2> f.actions
irb(main):004:2> end
irb(main):005:1>
此外,semantic_form_for
本身工作正常,但nested_form_for
(不semantic_
部分)不工作,導致我認爲這是直接關係到nested_form
。
我不認爲再培訓局的代碼是這個問題真的很重要,但在這裏它是無論如何:
<%= semantic_nested_form_for(@volume) do |f| %>
<%= f.inputs do %>
<%= f.input :number, label: 'Volume #', input_html: {autofocus: true}, hint: 'Choose the volume number.' %>
<% end %>
<div id="issues_fields">
<%= f.semantic_fields_for :issues %>
<%= f.link_to_add 'Add an Issue', :issues %>
</div>
<%= f.actions do %>
<%= f.action :submit, label: 'Save' %>
<% end %>
<% end %>
謝謝,剛剛有同樣的問題,想知道爲什麼那該死的功能wasnt工作 – Skully 2013-05-23 15:00:03
謝謝!重新啓動也爲我工作,但與simple_nested_form而不是semantic_nested_form_for。我沒有這種行爲的理由,但我也想理解這一點。 – evedovelli 2015-06-10 11:07:53