Topic: Undefined local variable for a partial. 2.3.2 bug or just me?[SOLVED]

I am refactoring one of my partials into 3 seperate partials.
If someone feels like playing a game of "Spot the deliberate mistake" I'd appreciate it coz I'm totally stumped.

undefined local variable or method `edit_form_id' for #<ActionView::Base:0x4353fc8>

Extracted source (around line #24):

21:       <%= f.text_field :postcode -%>
22:     </p>
23:   <%= link_to_function "Close",
24:     "jQuery('##{edit_form_id}').hide('slow')"-%>
25: </fieldset>

Now my first thought was that I had a typo in my :locals assignment but that is not the case.
I did a deliberate copy and paste of the variable name just to make absolutely certain, but no joy.
I even tried swapping round the locals to pass the edit_form_id variable BEFORE the form builder variable but that made no difference either.

What is even more confusing is that if I had my :locals declaration wrong then I would have thought that the error would have picked up the :f variable first since it's used in the partial before the edit_form_id variable is used.

I can't believe that this is a Rails 2.3.2 bug it has to be me missing something totally stupid.
The code worked perfectly before I split it out into partials.

I have tried server restarting and PC re-booting and I'm at a total loss.

<div id =<%=edit_form_id-%> style="display: none">
  <%= render(:partial => 'address_form',
              :locals => {:edit_form_id => edit_form_id, :f => f}) -%>
</div>

_address_form.html.erb

<fieldset>
  <legend>Details...</legend>
    <p>
      House name/number<br />
      <%= f.text_field :house -%>
    </p>
    <p>
      Street<br />
      <%= f.text_field :street -%>
    </p>
    <p>
      Town<br />
      <%= f.text_field :town -%>
    </p>
    <p>
      city<br />
      <%= f.text_field :city -%>
    </p>
    <p>
      Postcode<br />
      <%= f.text_field :postcode -%>
    </p>
  <%= link_to_function "Close",
    "jQuery('##{edit_form_id}').hide('slow')"-%>
</fieldset>

Last edited by jamesw (2009-08-21 11:31:49)

What you want and what you need are too often not the same thing!
When your head is hurting from trying to solve a problem, stop standing on it. When you are the right way up you will see the problem differently and you just might find the solution.
(Quote by me 15th July 2009)

Re: Undefined local variable for a partial. 2.3.2 bug or just me?[SOLVED]

It works ok for me on 2.3.2 using a straight copy and paste of your code...could it be something in the code that renders the first partial? I used:

<%= render :partial => 'test_one', :locals => { :edit_form_id => 'bob', :f => f } %>

Where the test_one partial is:

<div id =<%=edit_form_id-%> style="display: none">
  <%= render(:partial => 'address_form',
              :locals => {:edit_form_id => edit_form_id, :f => f}) -%>
</div>

Last edited by rob-twf (2009-08-21 04:43:48)

Rob Anderton
TheWebFellas

Re: Undefined local variable for a partial. 2.3.2 bug or just me?[SOLVED]

Thanks Rob.
I was starting to come to the same conclusion.
I'm finishing off the refactoring which will better enable me to tack this down but I think my problem may be with a jQuery link helper that generates this form.

  def link_to_create_address(form_builder)
    link_to_function 'New address' do |page|
      form_builder.fields_for :addresses, Address.new, :child_index => 'NEW_RECORD' do |f|
      html = render(:partial => 'address_container', :locals => { :f => f, :uid => 'NEW_RECORD' })
        page << "jQuery('#address_list').prepend('#{escape_javascript(html)}'.replace(/NEW_RECORD/g, new Date().getTime()))"
      end
    end
  end

The div declaration was slightly wrong so I have changed

<div id =<%=edit_form_id-%> style="display: none">

To this because I forgot to put the ID in quotes so it looks like this

<div id ="<%=edit_form_id-%>" style="display: none">

This reduced the number of W3C validation errors considerably but didn't have any effect on the problem itself.

I have moved the offending line back into the containing partial for the minuite whilst I finish the refactoring which will make it easier to debug.

I'll post back here when I have it sorted.

What you want and what you need are too often not the same thing!
When your head is hurting from trying to solve a problem, stop standing on it. When you are the right way up you will see the problem differently and you just might find the solution.
(Quote by me 15th July 2009)

Re: Undefined local variable for a partial. 2.3.2 bug or just me?[SOLVED]

I'm pretty sure you are not passing the value to the partial, which rob already mentioned.

Re: Undefined local variable for a partial. 2.3.2 bug or just me?[SOLVED]

Rob,
I forgot to say thank you very much for taking the trouble to try that out. It was a big help in preventing me from cracking up and totally loosing the plot. I thought I was going mad. lol.

Cherring,

cherring wrote:

I'm pretty sure you are not passing the value to the partial, which rob already mentioned.

Thank's Cherring. There is definitely something in what you say.
I've just finished refactoring my forms and the problem has moved to a different partial and a different variable but it's the same error and I'm stating to suspect that I have stuffed up my fields_for declaration somehow.

The new error is at the bottom of the page.

I'm hoping that by typing this explanation out something will become blindingly obvious.

users have many addresses and this is about maintaining users and addresses in the same page.

The user edit.html.erb view has the job of rendering a containing partial _container.html.erb.
This container renders a partial that has the user field maintenance fields, namely _form.html.erb.
In addition to this the container has the job of rendering the address details belonging to the user. These address details are wrapped up in a partial called _address_container.html.erb and live inside the context of a form_for @user

The address_container partial deals with one address and is called for each address in the user.addresses relationship. It is this partial that I now believe to be the culprit of my headache.

This address_container partial has the responsibility of showing a single line of address info with a link to show a hidden address form.
It is this form that I am refactoring to include 2 more partials. 1 to show the list style address detail and one to deal with the address form
Both these partials are inside the context of a fields_for :addresses declaration and are called _address_list and _address_form

The form code then goes like this
edit.html.erb

<h3>Editing <%= show_user_type %> </h3>

<% form_for([:admin, @user]) do |fuser| %>

  <%= render :partial => 'container', :locals => {:fuser => fuser} %>
  <p>
  <%= fuser.submit "Update" %>
  </p>
<% end %>

<%= link_to 'Show', [:admin, @user] %> |
<%= link_to 'Back', admin_users_path %>

_container.html.erb

<%= fuser.error_messages -%>
<%= render :partial => 'form', :locals => {:fuser => fuser} %> <!-- This works great -->
<h3>Addresses</h3>
<%= link_to_toggle_div('address_list', 'Addresses') %>
<%= link_to_create_address(fuser)%>
<div id ="address_list">
    <% fuser.fields_for :addresses do |faddress| %>

      <!-- This following render is at the root of the problem I think!!!!!  -->

      <%= render :partial => 'address_container', :locals => {:faddress => faddress} %>
    <% end %>
</div>

_address_container

<%if faddress.object.new_record? %>
  <%-list_form_id = "address-list-form-#{uid}"-%>
  <%-edit_form_id = "address-edit-form-#{uid}"-%>
<%-else-%>
  <%-list_form_id = "address-list-form-#{faddress.object_id}"-%>
  <%-edit_form_id = "address-edit-form-#{faddress.object_id}"-%>
<%-end-%>
<div id ="<%=list_form_id-%>">
  <%= render :partial => 'address_list',
             :locals => {:address => faddress.object,
                         :edit_form_id => edit_form_id} -%>
</div>
<div id ="<%=edit_form_id-%>" style="display: none">
  <%= render(:partial => 'address_form',
              :locals => {:faddress => faddress,
              :edit_form_id => edit_form_id}) -%>
  <%= link_to_hide_div(edit_form_id)-%>
</div>

The new error is

NameError in Admin/users#edit

Showing app/views/admin/users/_address_container.erb where line #1 raised:

undefined local variable or method `faddress' for #<ActionView::Base:0x4466e74>

Extracted source (around line #1):

1: <%if faddress.object.new_record? %>
2:   <%-list_form_id = "address-list-form-#{uid}"-%>
3:   <%-edit_form_id = "address-edit-form-#{uid}"-%>
4: <%-else-%>

Trace of template inclusion: app/views/admin/users/_container.html.erb, app/views/admin/users/edit.html.erb

RAILS_ROOT: C:/Development/Aptana/cloud_community
Application Trace | Framework Trace | Full Trace

C:/Development/Aptana/cloud_community/app/views/admin/users/_address_container.erb:1:in `_run_erb_app47views47admin47users47_address_container46erb_locals_address_container_f_object_uid'
C:/Development/Aptana/cloud_community/app/helpers/application_helper.rb:69:in `__instance_exec0'
C:/Development/Aptana/cloud_community/app/helpers/application_helper.rb:68:in `__instance_exec0'
C:/Development/Aptana/cloud_community/app/helpers/application_helper.rb:67:in `link_to_create_address'
C:/Development/Aptana/cloud_community/app/views/admin/users/_container.html.erb:5:in `_run_erb_app47views47admin47users47_container46html46erb_locals_container_fuser_object'
C:/Development/Aptana/cloud_community/app/views/admin/users/edit.html.erb:5:in `_run_erb_app47views47admin47users47edit46html46erb'
C:/Development/Aptana/cloud_community/app/views/admin/users/edit.html.erb:3:in `_run_erb_app47views47admin47users47edit46html46erb'

C:/Development/Aptana/cloud_community/vendor/rails/actionpack/lib/action_view/renderable.rb:34:in `send'
C:/Development/Aptana/cloud_community/vendor/rails/actionpack/lib/action_view/renderable.rb:34:in `render'
C:/Development/Aptana/cloud_community/vendor/rails/actionpack/lib/action_view/base.rb:301:in `with_template'
C:/Development/Aptana/cloud_community/vendor/rails/actionpack/lib/action_view/renderable.rb:30:in `render'
C:/Development/Aptana/cloud_community/vendor/rails/actionpack/lib/action_view/renderable_partial.rb:20:in `render'
C:/Development/Aptana/cloud_community/vendor/rails/actionpack/lib/action_controller/benchmarking.rb:26:in `benchmark'
C:/Development/Aptana/cloud_community/vendor/rails/activesupport/lib/active_support/core_ext/benchmark.rb:17:in `ms'
C:/Development/Aptana/cloud_community/vendor/rails/activesupport/lib/active_support/core_ext/benchmark.rb:10:in `realtime'
C:/Development/Aptana/cloud_community/vendor/rails/activesupport/lib/active_support/core_ext/benchmark.rb:17:in `ms'
C:/Development/Aptana/cloud_community/vendor/rails/actionpack/lib/action_controller/benchmarking.rb:26:in `benchmark'
C:/Development/Aptana/cloud_community/vendor/rails/actionpack/lib/action_view/renderable_partial.rb:19:in `render'
C:/Development/Aptana/cloud_community/vendor/rails/actionpack/lib/action_view/template.rb:199:in `render_template'
C:/Development/Aptana/cloud_community/vendor/rails/actionpack/lib/action_view/renderable_partial.rb:44:in `render_partial'
C:/Development/Aptana/cloud_community/vendor/rails/actionpack/lib/action_view/partials.rb:184:in `render_partial'
C:/Development/Aptana/cloud_community/vendor/rails/actionpack/lib/action_view/base.rb:262:in `render'
C:/Development/Aptana/cloud_community/vendor/rails/actionpack/lib/action_view/helpers/form_helper.rb:490:in `fields_for'
C:/Development/Aptana/cloud_community/vendor/rails/actionpack/lib/action_view/helpers/form_helper.rb:1032:in `fields_for_nested_model'
C:/Development/Aptana/cloud_community/vendor/rails/actionpack/lib/action_view/helpers/form_helper.rb:1023:in `fields_for_with_nested_attributes'
C:/Development/Aptana/cloud_community/vendor/rails/actionpack/lib/action_view/helpers/form_helper.rb:1022:in `map'
C:/Development/Aptana/cloud_community/vendor/rails/actionpack/lib/action_view/helpers/form_helper.rb:1022:in `fields_for_with_nested_attributes'
C:/Development/Aptana/cloud_community/vendor/rails/actionpack/lib/action_view/helpers/form_helper.rb:963:in `fields_for'
C:/Development/Aptana/cloud_community/vendor/rails/activesupport/lib/active_support/core_ext/object/extending.rb:74:in `send'
C:/Development/Aptana/cloud_community/vendor/rails/activesupport/lib/active_support/core_ext/object/extending.rb:74:in `instance_exec'
C:/Development/Aptana/cloud_community/vendor/rails/actionpack/lib/action_view/helpers/prototype_helper.rb:578:in `initialize'
C:/Development/Aptana/cloud_community/vendor/rails/actionpack/lib/action_view/helpers/capture_helper.rb:129:in `with_output_buffer'
C:/Development/Aptana/cloud_community/vendor/rails/actionpack/lib/action_view/helpers/prototype_helper.rb:577:in `initialize'
C:/Development/Aptana/cloud_community/vendor/rails/actionpack/lib/action_view/helpers/prototype_helper.rb:1029:in `new'
C:/Development/Aptana/cloud_community/vendor/rails/actionpack/lib/action_view/helpers/prototype_helper.rb:1029:in `update_page'
C:/Development/Aptana/cloud_community/vendor/rails/actionpack/lib/action_view/helpers/javascript_helper.rb:91:in `link_to_function'
C:/Development/Aptana/cloud_community/vendor/rails/actionpack/lib/action_view/renderable.rb:34:in `send'
C:/Development/Aptana/cloud_community/vendor/rails/actionpack/lib/action_view/renderable.rb:34:in `render'
C:/Development/Aptana/cloud_community/vendor/rails/actionpack/lib/action_view/base.rb:301:in `with_template'
C:/Development/Aptana/cloud_community/vendor/rails/actionpack/lib/action_view/renderable.rb:30:in `render'
C:/Development/Aptana/cloud_community/vendor/rails/actionpack/lib/action_view/renderable_partial.rb:20:in `render'
C:/Development/Aptana/cloud_community/vendor/rails/actionpack/lib/action_controller/benchmarking.rb:26:in `benchmark'
C:/Development/Aptana/cloud_community/vendor/rails/activesupport/lib/active_support/core_ext/benchmark.rb:17:in `ms'
C:/Development/Aptana/cloud_community/vendor/rails/activesupport/lib/active_support/core_ext/benchmark.rb:10:in `realtime'
C:/Development/Aptana/cloud_community/vendor/rails/activesupport/lib/active_support/core_ext/benchmark.rb:17:in `ms'
C:/Development/Aptana/cloud_community/vendor/rails/actionpack/lib/action_controller/benchmarking.rb:26:in `benchmark'
C:/Development/Aptana/cloud_community/vendor/rails/actionpack/lib/action_view/renderable_partial.rb:19:in `render'
C:/Development/Aptana/cloud_community/vendor/rails/actionpack/lib/action_view/template.rb:199:in `render_template'
C:/Development/Aptana/cloud_community/vendor/rails/actionpack/lib/action_view/renderable_partial.rb:44:in `render_partial'
C:/Development/Aptana/cloud_community/vendor/rails/actionpack/lib/action_view/partials.rb:184:in `render_partial'
C:/Development/Aptana/cloud_community/vendor/rails/actionpack/lib/action_view/base.rb:262:in `render'
C:/Development/Aptana/cloud_community/vendor/rails/actionpack/lib/action_view/helpers/form_helper.rb:490:in `fields_for'
C:/Development/Aptana/cloud_community/vendor/rails/actionpack/lib/action_view/helpers/form_helper.rb:282:in `form_for'
C:/Development/Aptana/cloud_community/vendor/rails/actionpack/lib/action_view/renderable.rb:34:in `send'
C:/Development/Aptana/cloud_community/vendor/rails/actionpack/lib/action_view/renderable.rb:34:in `render'
C:/Development/Aptana/cloud_community/vendor/rails/actionpack/lib/action_view/base.rb:301:in `with_template'
C:/Development/Aptana/cloud_community/vendor/rails/actionpack/lib/action_view/renderable.rb:30:in `render'
C:/Development/Aptana/cloud_community/vendor/rails/actionpack/lib/action_view/template.rb:199:in `render_template'
C:/Development/Aptana/cloud_community/vendor/rails/actionpack/lib/action_view/base.rb:260:in `render'
C:/Development/Aptana/cloud_community/vendor/rails/actionpack/lib/action_view/base.rb:343:in `_render_with_layout'
C:/Development/Aptana/cloud_community/vendor/rails/actionpack/lib/action_view/base.rb:257:in `render'
C:/Development/Aptana/cloud_community/vendor/rails/actionpack/lib/action_controller/base.rb:1246:in `render_for_file'
C:/Development/Aptana/cloud_community/vendor/rails/actionpack/lib/action_controller/base.rb:941:in `render_without_benchmark'
C:/Development/Aptana/cloud_community/vendor/rails/actionpack/lib/action_controller/benchmarking.rb:51:in `render'
C:/Development/Aptana/cloud_community/vendor/rails/activesupport/lib/active_support/core_ext/benchmark.rb:17:in `ms'
C:/Development/Aptana/cloud_community/vendor/rails/activesupport/lib/active_support/core_ext/benchmark.rb:10:in `realtime'
C:/Development/Aptana/cloud_community/vendor/rails/activesupport/lib/active_support/core_ext/benchmark.rb:17:in `ms'
C:/Development/Aptana/cloud_community/vendor/rails/actionpack/lib/action_controller/benchmarking.rb:51:in `render'
C:/Development/Aptana/cloud_community/vendor/rails/actionpack/lib/action_controller/base.rb:1322:in `default_render'
C:/Development/Aptana/cloud_community/vendor/rails/actionpack/lib/action_controller/base.rb:1328:in `perform_action_without_filters'
C:/Development/Aptana/cloud_community/vendor/rails/actionpack/lib/action_controller/filters.rb:617:in `call_filters'
C:/Development/Aptana/cloud_community/vendor/rails/actionpack/lib/action_controller/filters.rb:610:in `perform_action_without_benchmark'
C:/Development/Aptana/cloud_community/vendor/rails/actionpack/lib/action_controller/benchmarking.rb:68:in `perform_action_without_rescue'
C:/Development/Aptana/cloud_community/vendor/rails/activesupport/lib/active_support/core_ext/benchmark.rb:17:in `ms'
C:/Development/Aptana/cloud_community/vendor/rails/activesupport/lib/active_support/core_ext/benchmark.rb:10:in `realtime'
C:/Development/Aptana/cloud_community/vendor/rails/activesupport/lib/active_support/core_ext/benchmark.rb:17:in `ms'
C:/Development/Aptana/cloud_community/vendor/rails/actionpack/lib/action_controller/benchmarking.rb:68:in `perform_action_without_rescue'
C:/Development/Aptana/cloud_community/vendor/rails/actionpack/lib/action_controller/rescue.rb:160:in `perform_action_without_flash'
C:/Development/Aptana/cloud_community/vendor/rails/actionpack/lib/action_controller/flash.rb:146:in `perform_action'
C:/Development/Aptana/cloud_community/vendor/rails/actionpack/lib/action_controller/base.rb:527:in `send'
C:/Development/Aptana/cloud_community/vendor/rails/actionpack/lib/action_controller/base.rb:527:in `process_without_filters'
C:/Development/Aptana/cloud_community/vendor/rails/actionpack/lib/action_controller/filters.rb:606:in `process'
C:/Development/Aptana/cloud_community/vendor/rails/actionpack/lib/action_controller/base.rb:391:in `process'
C:/Development/Aptana/cloud_community/vendor/rails/actionpack/lib/action_controller/base.rb:386:in `call'
C:/Development/Aptana/cloud_community/vendor/rails/actionpack/lib/action_controller/routing/route_set.rb:434:in `call'
C:/Development/Aptana/cloud_community/vendor/rails/actionpack/lib/action_controller/dispatcher.rb:88:in `dispatch'
C:/Development/Aptana/cloud_community/vendor/rails/actionpack/lib/action_controller/dispatcher.rb:111:in `_call'
C:/Development/Aptana/cloud_community/vendor/rails/actionpack/lib/action_controller/dispatcher.rb:82:in `initialize'
C:/Development/InstantRails/ruby/lib/ruby/gems/1.8/gems/rack-1.0.0/lib/rack/head.rb:9:in `call'
C:/Development/InstantRails/ruby/lib/ruby/gems/1.8/gems/rack-1.0.0/lib/rack/head.rb:9:in `call'
C:/Development/InstantRails/ruby/lib/ruby/gems/1.8/gems/rack-1.0.0/lib/rack/methodoverride.rb:24:in `call'
C:/Development/Aptana/cloud_community/vendor/rails/actionpack/lib/action_controller/params_parser.rb:15:in `call'
C:/Development/Aptana/cloud_community/vendor/rails/actionpack/lib/action_controller/session/abstract_store.rb:122:in `call'
C:/Development/Aptana/cloud_community/vendor/rails/activerecord/lib/active_record/query_cache.rb:29:in `call'
C:/Development/Aptana/cloud_community/vendor/rails/activerecord/lib/active_record/connection_adapters/abstract/query_cache.rb:34:in `cache'
C:/Development/Aptana/cloud_community/vendor/rails/activerecord/lib/active_record/query_cache.rb:9:in `cache'
C:/Development/Aptana/cloud_community/vendor/rails/activerecord/lib/active_record/query_cache.rb:28:in `call'
C:/Development/Aptana/cloud_community/vendor/rails/activerecord/lib/active_record/connection_adapters/abstract/connection_pool.rb:361:in `call'
C:/Development/Aptana/cloud_community/vendor/rails/actionpack/lib/action_controller/reloader.rb:29:in `call'
C:/Development/Aptana/cloud_community/vendor/rails/actionpack/lib/action_controller/failsafe.rb:26:in `call'
C:/Development/InstantRails/ruby/lib/ruby/gems/1.8/gems/rack-1.0.0/lib/rack/lock.rb:11:in `call'
C:/Development/InstantRails/ruby/lib/ruby/gems/1.8/gems/rack-1.0.0/lib/rack/lock.rb:11:in `synchronize'
C:/Development/InstantRails/ruby/lib/ruby/gems/1.8/gems/rack-1.0.0/lib/rack/lock.rb:11:in `call'
C:/Development/Aptana/cloud_community/vendor/rails/actionpack/lib/action_controller/dispatcher.rb:106:in `call'
C:/Development/Aptana/cloud_community/vendor/rails/railties/lib/rails/rack/static.rb:31:in `call'
C:/Development/InstantRails/ruby/lib/ruby/gems/1.8/gems/rack-1.0.0/lib/rack/urlmap.rb:46:in `call'
C:/Development/InstantRails/ruby/lib/ruby/gems/1.8/gems/rack-1.0.0/lib/rack/urlmap.rb:40:in `each'
C:/Development/InstantRails/ruby/lib/ruby/gems/1.8/gems/rack-1.0.0/lib/rack/urlmap.rb:40:in `call'
C:/Development/Aptana/cloud_community/vendor/rails/railties/lib/rails/rack/log_tailer.rb:17:in `call'
C:/Development/InstantRails/ruby/lib/ruby/gems/1.8/gems/rack-1.0.0/lib/rack/content_length.rb:13:in `call'
C:/Development/InstantRails/ruby/lib/ruby/gems/1.8/gems/rack-1.0.0/lib/rack/handler/webrick.rb:46:in `service'
C:/Development/InstantRails/ruby/lib/ruby/1.8/webrick/httpserver.rb:104:in `service'
C:/Development/InstantRails/ruby/lib/ruby/1.8/webrick/httpserver.rb:65:in `run'
C:/Development/InstantRails/ruby/lib/ruby/1.8/webrick/server.rb:173:in `start_thread'
C:/Development/InstantRails/ruby/lib/ruby/1.8/webrick/server.rb:162:in `start'
C:/Development/InstantRails/ruby/lib/ruby/1.8/webrick/server.rb:162:in `start_thread'
C:/Development/InstantRails/ruby/lib/ruby/1.8/webrick/server.rb:95:in `start'
C:/Development/InstantRails/ruby/lib/ruby/1.8/webrick/server.rb:92:in `each'
C:/Development/InstantRails/ruby/lib/ruby/1.8/webrick/server.rb:92:in `start'
C:/Development/InstantRails/ruby/lib/ruby/1.8/webrick/server.rb:23:in `start'
C:/Development/InstantRails/ruby/lib/ruby/1.8/webrick/server.rb:82:in `start'
C:/Development/InstantRails/ruby/lib/ruby/gems/1.8/gems/rack-1.0.0/lib/rack/handler/webrick.rb:13:in `run'
C:/Development/Aptana/cloud_community/vendor/rails/railties/lib/commands/server.rb:111
C:/Development/InstantRails/ruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `gem_original_require'
C:/Development/InstantRails/ruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `require'
script/server:3

C:/Development/Aptana/cloud_community/app/views/admin/users/_address_container.erb:1:in `_run_erb_app47views47admin47users47_address_container46erb_locals_address_container_f_object_uid'
C:/Development/Aptana/cloud_community/vendor/rails/actionpack/lib/action_view/renderable.rb:34:in `send'
C:/Development/Aptana/cloud_community/vendor/rails/actionpack/lib/action_view/renderable.rb:34:in `render'
C:/Development/Aptana/cloud_community/vendor/rails/actionpack/lib/action_view/base.rb:301:in `with_template'
C:/Development/Aptana/cloud_community/vendor/rails/actionpack/lib/action_view/renderable.rb:30:in `render'
C:/Development/Aptana/cloud_community/vendor/rails/actionpack/lib/action_view/renderable_partial.rb:20:in `render'
C:/Development/Aptana/cloud_community/vendor/rails/actionpack/lib/action_controller/benchmarking.rb:26:in `benchmark'
C:/Development/Aptana/cloud_community/vendor/rails/activesupport/lib/active_support/core_ext/benchmark.rb:17:in `ms'
C:/Development/Aptana/cloud_community/vendor/rails/activesupport/lib/active_support/core_ext/benchmark.rb:10:in `realtime'
C:/Development/Aptana/cloud_community/vendor/rails/activesupport/lib/active_support/core_ext/benchmark.rb:17:in `ms'
C:/Development/Aptana/cloud_community/vendor/rails/actionpack/lib/action_controller/benchmarking.rb:26:in `benchmark'
C:/Development/Aptana/cloud_community/vendor/rails/actionpack/lib/action_view/renderable_partial.rb:19:in `render'
C:/Development/Aptana/cloud_community/vendor/rails/actionpack/lib/action_view/template.rb:199:in `render_template'
C:/Development/Aptana/cloud_community/vendor/rails/actionpack/lib/action_view/renderable_partial.rb:44:in `render_partial'
C:/Development/Aptana/cloud_community/vendor/rails/actionpack/lib/action_view/partials.rb:184:in `render_partial'
C:/Development/Aptana/cloud_community/vendor/rails/actionpack/lib/action_view/base.rb:262:in `render'
C:/Development/Aptana/cloud_community/app/helpers/application_helper.rb:69:in `__instance_exec0'
C:/Development/Aptana/cloud_community/vendor/rails/actionpack/lib/action_view/helpers/form_helper.rb:490:in `fields_for'
C:/Development/Aptana/cloud_community/vendor/rails/actionpack/lib/action_view/helpers/form_helper.rb:1032:in `fields_for_nested_model'
C:/Development/Aptana/cloud_community/vendor/rails/actionpack/lib/action_view/helpers/form_helper.rb:1023:in `fields_for_with_nested_attributes'
C:/Development/Aptana/cloud_community/vendor/rails/actionpack/lib/action_view/helpers/form_helper.rb:1022:in `map'
C:/Development/Aptana/cloud_community/vendor/rails/actionpack/lib/action_view/helpers/form_helper.rb:1022:in `fields_for_with_nested_attributes'
C:/Development/Aptana/cloud_community/vendor/rails/actionpack/lib/action_view/helpers/form_helper.rb:963:in `fields_for'
C:/Development/Aptana/cloud_community/app/helpers/application_helper.rb:68:in `__instance_exec0'
C:/Development/Aptana/cloud_community/vendor/rails/activesupport/lib/active_support/core_ext/object/extending.rb:74:in `send'
C:/Development/Aptana/cloud_community/vendor/rails/activesupport/lib/active_support/core_ext/object/extending.rb:74:in `instance_exec'
C:/Development/Aptana/cloud_community/vendor/rails/actionpack/lib/action_view/helpers/prototype_helper.rb:578:in `initialize'
C:/Development/Aptana/cloud_community/vendor/rails/actionpack/lib/action_view/helpers/capture_helper.rb:129:in `with_output_buffer'
C:/Development/Aptana/cloud_community/vendor/rails/actionpack/lib/action_view/helpers/prototype_helper.rb:577:in `initialize'
C:/Development/Aptana/cloud_community/vendor/rails/actionpack/lib/action_view/helpers/prototype_helper.rb:1029:in `new'
C:/Development/Aptana/cloud_community/vendor/rails/actionpack/lib/action_view/helpers/prototype_helper.rb:1029:in `update_page'
C:/Development/Aptana/cloud_community/vendor/rails/actionpack/lib/action_view/helpers/javascript_helper.rb:91:in `link_to_function'
C:/Development/Aptana/cloud_community/app/helpers/application_helper.rb:67:in `link_to_create_address'
C:/Development/Aptana/cloud_community/app/views/admin/users/_container.html.erb:5:in `_run_erb_app47views47admin47users47_container46html46erb_locals_container_fuser_object'
C:/Development/Aptana/cloud_community/vendor/rails/actionpack/lib/action_view/renderable.rb:34:in `send'
C:/Development/Aptana/cloud_community/vendor/rails/actionpack/lib/action_view/renderable.rb:34:in `render'
C:/Development/Aptana/cloud_community/vendor/rails/actionpack/lib/action_view/base.rb:301:in `with_template'
C:/Development/Aptana/cloud_community/vendor/rails/actionpack/lib/action_view/renderable.rb:30:in `render'
C:/Development/Aptana/cloud_community/vendor/rails/actionpack/lib/action_view/renderable_partial.rb:20:in `render'
C:/Development/Aptana/cloud_community/vendor/rails/actionpack/lib/action_controller/benchmarking.rb:26:in `benchmark'
C:/Development/Aptana/cloud_community/vendor/rails/activesupport/lib/active_support/core_ext/benchmark.rb:17:in `ms'
C:/Development/Aptana/cloud_community/vendor/rails/activesupport/lib/active_support/core_ext/benchmark.rb:10:in `realtime'
C:/Development/Aptana/cloud_community/vendor/rails/activesupport/lib/active_support/core_ext/benchmark.rb:17:in `ms'
C:/Development/Aptana/cloud_community/vendor/rails/actionpack/lib/action_controller/benchmarking.rb:26:in `benchmark'
C:/Development/Aptana/cloud_community/vendor/rails/actionpack/lib/action_view/renderable_partial.rb:19:in `render'
C:/Development/Aptana/cloud_community/vendor/rails/actionpack/lib/action_view/template.rb:199:in `render_template'
C:/Development/Aptana/cloud_community/vendor/rails/actionpack/lib/action_view/renderable_partial.rb:44:in `render_partial'
C:/Development/Aptana/cloud_community/vendor/rails/actionpack/lib/action_view/partials.rb:184:in `render_partial'
C:/Development/Aptana/cloud_community/vendor/rails/actionpack/lib/action_view/base.rb:262:in `render'
C:/Development/Aptana/cloud_community/app/views/admin/users/edit.html.erb:5:in `_run_erb_app47views47admin47users47edit46html46erb'
C:/Development/Aptana/cloud_community/vendor/rails/actionpack/lib/action_view/helpers/form_helper.rb:490:in `fields_for'
C:/Development/Aptana/cloud_community/vendor/rails/actionpack/lib/action_view/helpers/form_helper.rb:282:in `form_for'
C:/Development/Aptana/cloud_community/app/views/admin/users/edit.html.erb:3:in `_run_erb_app47views47admin47users47edit46html46erb'
C:/Development/Aptana/cloud_community/vendor/rails/actionpack/lib/action_view/renderable.rb:34:in `send'
C:/Development/Aptana/cloud_community/vendor/rails/actionpack/lib/action_view/renderable.rb:34:in `render'
C:/Development/Aptana/cloud_community/vendor/rails/actionpack/lib/action_view/base.rb:301:in `with_template'
C:/Development/Aptana/cloud_community/vendor/rails/actionpack/lib/action_view/renderable.rb:30:in `render'
C:/Development/Aptana/cloud_community/vendor/rails/actionpack/lib/action_view/template.rb:199:in `render_template'
C:/Development/Aptana/cloud_community/vendor/rails/actionpack/lib/action_view/base.rb:260:in `render'
C:/Development/Aptana/cloud_community/vendor/rails/actionpack/lib/action_view/base.rb:343:in `_render_with_layout'
C:/Development/Aptana/cloud_community/vendor/rails/actionpack/lib/action_view/base.rb:257:in `render'
C:/Development/Aptana/cloud_community/vendor/rails/actionpack/lib/action_controller/base.rb:1246:in `render_for_file'
C:/Development/Aptana/cloud_community/vendor/rails/actionpack/lib/action_controller/base.rb:941:in `render_without_benchmark'
C:/Development/Aptana/cloud_community/vendor/rails/actionpack/lib/action_controller/benchmarking.rb:51:in `render'
C:/Development/Aptana/cloud_community/vendor/rails/activesupport/lib/active_support/core_ext/benchmark.rb:17:in `ms'
C:/Development/Aptana/cloud_community/vendor/rails/activesupport/lib/active_support/core_ext/benchmark.rb:10:in `realtime'
C:/Development/Aptana/cloud_community/vendor/rails/activesupport/lib/active_support/core_ext/benchmark.rb:17:in `ms'
C:/Development/Aptana/cloud_community/vendor/rails/actionpack/lib/action_controller/benchmarking.rb:51:in `render'
C:/Development/Aptana/cloud_community/vendor/rails/actionpack/lib/action_controller/base.rb:1322:in `default_render'
C:/Development/Aptana/cloud_community/vendor/rails/actionpack/lib/action_controller/base.rb:1328:in `perform_action_without_filters'
C:/Development/Aptana/cloud_community/vendor/rails/actionpack/lib/action_controller/filters.rb:617:in `call_filters'
C:/Development/Aptana/cloud_community/vendor/rails/actionpack/lib/action_controller/filters.rb:610:in `perform_action_without_benchmark'
C:/Development/Aptana/cloud_community/vendor/rails/actionpack/lib/action_controller/benchmarking.rb:68:in `perform_action_without_rescue'
C:/Development/Aptana/cloud_community/vendor/rails/activesupport/lib/active_support/core_ext/benchmark.rb:17:in `ms'
C:/Development/Aptana/cloud_community/vendor/rails/activesupport/lib/active_support/core_ext/benchmark.rb:10:in `realtime'
C:/Development/Aptana/cloud_community/vendor/rails/activesupport/lib/active_support/core_ext/benchmark.rb:17:in `ms'
C:/Development/Aptana/cloud_community/vendor/rails/actionpack/lib/action_controller/benchmarking.rb:68:in `perform_action_without_rescue'
C:/Development/Aptana/cloud_community/vendor/rails/actionpack/lib/action_controller/rescue.rb:160:in `perform_action_without_flash'
C:/Development/Aptana/cloud_community/vendor/rails/actionpack/lib/action_controller/flash.rb:146:in `perform_action'
C:/Development/Aptana/cloud_community/vendor/rails/actionpack/lib/action_controller/base.rb:527:in `send'
C:/Development/Aptana/cloud_community/vendor/rails/actionpack/lib/action_controller/base.rb:527:in `process_without_filters'
C:/Development/Aptana/cloud_community/vendor/rails/actionpack/lib/action_controller/filters.rb:606:in `process'
C:/Development/Aptana/cloud_community/vendor/rails/actionpack/lib/action_controller/base.rb:391:in `process'
C:/Development/Aptana/cloud_community/vendor/rails/actionpack/lib/action_controller/base.rb:386:in `call'
C:/Development/Aptana/cloud_community/vendor/rails/actionpack/lib/action_controller/routing/route_set.rb:434:in `call'
C:/Development/Aptana/cloud_community/vendor/rails/actionpack/lib/action_controller/dispatcher.rb:88:in `dispatch'
C:/Development/Aptana/cloud_community/vendor/rails/actionpack/lib/action_controller/dispatcher.rb:111:in `_call'
C:/Development/Aptana/cloud_community/vendor/rails/actionpack/lib/action_controller/dispatcher.rb:82:in `initialize'
C:/Development/InstantRails/ruby/lib/ruby/gems/1.8/gems/rack-1.0.0/lib/rack/head.rb:9:in `call'
C:/Development/InstantRails/ruby/lib/ruby/gems/1.8/gems/rack-1.0.0/lib/rack/head.rb:9:in `call'
C:/Development/InstantRails/ruby/lib/ruby/gems/1.8/gems/rack-1.0.0/lib/rack/methodoverride.rb:24:in `call'
C:/Development/Aptana/cloud_community/vendor/rails/actionpack/lib/action_controller/params_parser.rb:15:in `call'
C:/Development/Aptana/cloud_community/vendor/rails/actionpack/lib/action_controller/session/abstract_store.rb:122:in `call'
C:/Development/Aptana/cloud_community/vendor/rails/activerecord/lib/active_record/query_cache.rb:29:in `call'
C:/Development/Aptana/cloud_community/vendor/rails/activerecord/lib/active_record/connection_adapters/abstract/query_cache.rb:34:in `cache'
C:/Development/Aptana/cloud_community/vendor/rails/activerecord/lib/active_record/query_cache.rb:9:in `cache'
C:/Development/Aptana/cloud_community/vendor/rails/activerecord/lib/active_record/query_cache.rb:28:in `call'
C:/Development/Aptana/cloud_community/vendor/rails/activerecord/lib/active_record/connection_adapters/abstract/connection_pool.rb:361:in `call'
C:/Development/Aptana/cloud_community/vendor/rails/actionpack/lib/action_controller/reloader.rb:29:in `call'
C:/Development/Aptana/cloud_community/vendor/rails/actionpack/lib/action_controller/failsafe.rb:26:in `call'
C:/Development/InstantRails/ruby/lib/ruby/gems/1.8/gems/rack-1.0.0/lib/rack/lock.rb:11:in `call'
C:/Development/InstantRails/ruby/lib/ruby/gems/1.8/gems/rack-1.0.0/lib/rack/lock.rb:11:in `synchronize'
C:/Development/InstantRails/ruby/lib/ruby/gems/1.8/gems/rack-1.0.0/lib/rack/lock.rb:11:in `call'
C:/Development/Aptana/cloud_community/vendor/rails/actionpack/lib/action_controller/dispatcher.rb:106:in `call'
C:/Development/Aptana/cloud_community/vendor/rails/railties/lib/rails/rack/static.rb:31:in `call'
C:/Development/InstantRails/ruby/lib/ruby/gems/1.8/gems/rack-1.0.0/lib/rack/urlmap.rb:46:in `call'
C:/Development/InstantRails/ruby/lib/ruby/gems/1.8/gems/rack-1.0.0/lib/rack/urlmap.rb:40:in `each'
C:/Development/InstantRails/ruby/lib/ruby/gems/1.8/gems/rack-1.0.0/lib/rack/urlmap.rb:40:in `call'
C:/Development/Aptana/cloud_community/vendor/rails/railties/lib/rails/rack/log_tailer.rb:17:in `call'
C:/Development/InstantRails/ruby/lib/ruby/gems/1.8/gems/rack-1.0.0/lib/rack/content_length.rb:13:in `call'
C:/Development/InstantRails/ruby/lib/ruby/gems/1.8/gems/rack-1.0.0/lib/rack/handler/webrick.rb:46:in `service'
C:/Development/InstantRails/ruby/lib/ruby/1.8/webrick/httpserver.rb:104:in `service'
C:/Development/InstantRails/ruby/lib/ruby/1.8/webrick/httpserver.rb:65:in `run'
C:/Development/InstantRails/ruby/lib/ruby/1.8/webrick/server.rb:173:in `start_thread'
C:/Development/InstantRails/ruby/lib/ruby/1.8/webrick/server.rb:162:in `start'
C:/Development/InstantRails/ruby/lib/ruby/1.8/webrick/server.rb:162:in `start_thread'
C:/Development/InstantRails/ruby/lib/ruby/1.8/webrick/server.rb:95:in `start'
C:/Development/InstantRails/ruby/lib/ruby/1.8/webrick/server.rb:92:in `each'
C:/Development/InstantRails/ruby/lib/ruby/1.8/webrick/server.rb:92:in `start'
C:/Development/InstantRails/ruby/lib/ruby/1.8/webrick/server.rb:23:in `start'
C:/Development/InstantRails/ruby/lib/ruby/1.8/webrick/server.rb:82:in `start'
C:/Development/InstantRails/ruby/lib/ruby/gems/1.8/gems/rack-1.0.0/lib/rack/handler/webrick.rb:13:in `run'
C:/Development/Aptana/cloud_community/vendor/rails/railties/lib/commands/server.rb:111
C:/Development/InstantRails/ruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `gem_original_require'
C:/Development/InstantRails/ruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `require'
script/server:3

Request

Parameters:

{"id"=>"1"}

Show session dump

---

Response

Headers:

{"Content-Type"=>"text/html",
"Cache-Control"=>"no-cache"}

Last edited by jamesw (2009-08-21 10:58:32)

What you want and what you need are too often not the same thing!
When your head is hurting from trying to solve a problem, stop standing on it. When you are the right way up you will see the problem differently and you just might find the solution.
(Quote by me 15th July 2009)

Re: Undefined local variable for a partial. 2.3.2 bug or just me?[SOLVED]

Does the link_to_create_address helper try and render the partial too?

oh and coding cracked me up years ago... big_smile

Rob Anderton
TheWebFellas

Re: Undefined local variable for a partial. 2.3.2 bug or just me?[SOLVED]

Problem solved
The last error was down to the link_to_create_address_helper.

<%= fuser.error_messages -%>
<%= render :partial => 'form', :locals => {:fuser => fuser} %>
<h3>Addresses</h3>
<%= link_to_toggle_div('address_list', 'Addresses') %>
<%= link_to_create_address(fuser)%><!-- The code inside the helper for this function was wrong.-->
<div id ="address_list">
    <% fuser.fields_for :addresses do |faddress| %>
      <%= render :partial => 'address_container', :locals => {:faddress => faddress} %>
    <% end %>
</div>

I had the wrong locals parameter inside the helper and was using :f instead of :faddress
This was not the original cause of my problem though as this only changed as part of the refactoring process.

Having sorted that out I moved the original reference to edit_form_id back into the partial and for some reason everything now works.

So I am no closer to understanding what my original problem was but I need to move on
W3C validation is now down to only 3 errors from 110 and functionality is all good so I need to sort out the validation errors which are down to jQuery link_to problems and  and back to understanding this later.

Thanks for all the input.

What you want and what you need are too often not the same thing!
When your head is hurting from trying to solve a problem, stop standing on it. When you are the right way up you will see the problem differently and you just might find the solution.
(Quote by me 15th July 2009)

Re: Undefined local variable for a partial. 2.3.2 bug or just me?[SOLVED]

rob-twf wrote:

Does the link_to_create_address helper try and render the partial too?

oh and coding cracked me up years ago... big_smile

Yes it does!

  def link_to_create_address(form_builder)
    link_to_function 'New address' do |page|
      form_builder.fields_for :addresses, Address.new, :child_index => 'NEW_RECORD' do |faddress|
      html = render(:partial => 'address_container', :locals => { :faddress => faddress, :uid => 'NEW_RECORD' })
        page << "jQuery('#address_list').prepend('#{escape_javascript(html)}'.replace(/NEW_RECORD/g, new Date().getTime()))"
      end
    end
  end

I had to change this to fix the latest problem but now all is good and the original problem has just dissapeared. Very strange.

What you want and what you need are too often not the same thing!
When your head is hurting from trying to solve a problem, stop standing on it. When you are the right way up you will see the problem differently and you just might find the solution.
(Quote by me 15th July 2009)