I'm trying to switch a site to use the nested_form gem in combination with formtastic, which I'm already using, but I'm getting a strange error. Everything works perfectly fine in development, and tests pass. This error only occurs in production.
Visiting the page where semantic_nested_form_for
is used causes the following error:
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'
The gem is in my Gemfile and seems to be installed correctly:
[~/application/current]$ bundle show nested_form
/home/deployer/application/shared/bundle/ruby/1.9.1/gems/nested_form-0.3.1
I can even successfully call the semantic_nested_form_for
in the production console:
[~/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>
Additionally, semantic_form_for
works fine by itself, but nested_form_for
(without the semantic_
part) does NOT work, leading me to think this is related directly to nested_form
.
I don't think the erb code is really relevant to this issue, but here it is anyway:
<%= 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 %>
Well I'm a little dumbfounded. Capistrano restarts unicorn when I deploy, and before I asked this question I had tried manually restarting nginx and unicorn just to rule that out. After I asked the question I rebooted the entire production server (which I hate doing) just to see, and now it's working fine.
If anyone can tell me a good reason why simply rebooting the unicorn process wasn't enough, I'll mark their answer as the accepted answer.