title: Rails "undefined local variable or method" for an attr that isn't even refrenced
body: <p>I'm at a loss here. When running in Dev mode (script/server) I the error "<code>undefined local variable or method 'id' for #&lt;InsertModelNameHere:0x7f19bdb87dc8&gt;</code>" at random times when I try to list entries for a number of my models.  If I refresh the page it works fine and I'm assuming that I only see it in dev because everything gets reloaded for each request.  Maybe a race condition or something going on?  I'm not even referencing the "id" attribute (legacy table that uses a different key naming convention) in the views where this is an issue, One of my co-workers informed me that rails will create an "id" attribute based on the primary key defined in the model though.  </p>
  
  <p>Below is the code for the view, the error message,a and the stack trace.  I'm running rails 2.3.3.</p>
  
  <p>View:</p>
  
  <pre><code>&lt;h2 class="textCenter"&gt;To Do List&lt;/h2&gt;
  &lt;% form_tag({:action =&gt; "list"}, :method =&gt; "get") do %&gt;
      &lt;div class="full_width textCenter"&gt;
          &lt;%= text_field_tag "q", params[:q] %&gt;
          &lt;input type="submit" value="Search" /&gt;
      &lt;/div&gt;
  &lt;% end %&gt;
  &lt;table class="full_width list"&gt;
      &lt;thead &gt;
          &lt;tr &gt;
              &lt;th &gt;ID&lt;/th&gt;
              &lt;th &gt;Name&lt;/th&gt;
              &lt;th &gt;Resource ID&lt;/th&gt;
              &lt;th &gt;Company&lt;/th&gt;
              &lt;th &gt;&amp;nbsp;&lt;/th&gt;
              &lt;th &gt;&amp;nbsp;&lt;/th&gt;
          &lt;/tr&gt;
      &lt;/thead&gt;
      &lt;tbody &gt;
          &lt;% begin %&gt;
              &lt;% @todos.each do |todo| %&gt; 
                  &lt;tr class="&lt;%= cycle "striped", "" %&gt;" &gt;
                      &lt;td &gt;&lt;%= todo.pk_todo_id %&gt;&lt;/td&gt;
                      &lt;td &gt;&lt;%= todo.name %&gt;&lt;/td&gt;
                      &lt;td &gt;&lt;%= todo.fk_resource_id %&gt;&lt;/td&gt;
                      &lt;td &gt;&lt;%= todo.fk_company_id %&gt;&lt;/td&gt;
                      &lt;td &gt;&lt;%= link_to "STA", {:controller =&gt; "stas", :action =&gt; "list", :id =&gt; todo.fk_resource_id} %&gt;&lt;/td&gt;
                      &lt;td &gt;&lt;%= link_to "Edit", {:controller =&gt; "todos", :action =&gt; "edit", :id =&gt; todo.pk_todo_id} %&gt;&lt;/td&gt;
                  &lt;/tr&gt;
              &lt;% end %&gt;
          &lt;% rescue =&gt; e; puts e.message; puts e.backtrace %&gt;
          &lt;% end %&gt;
      &lt;/tbody&gt;
  &lt;/table&gt;
  </code></pre>
  
  <p>Error: <code>undefined local variable or method 'id' for #&lt;Todo:0x7f19bdb87dc8&gt;</code></p>
  
  <pre><code>/var/lib/gems/1.8/gems/activerecord-2.3.3/lib/active_record/attribute_methods.rb:260:in 'method_missing'
  /var/lib/gems/1.8/gems/activerecord-2.3.3/lib/active_record/attribute_methods.rb:249:in 'method_missing'
  /home/scott/Projects/cllsuite/trunk/app/views/todos/list.rhtml:25:in '_run_rhtml_app47views47todos47list46rhtml'
  /home/scott/Projects/cllsuite/trunk/app/views/todos/list.rhtml:23:in 'each'
  /home/scott/Projects/cllsuite/trunk/app/views/todos/list.rhtml:23:in '_run_rhtml_app47views47todos47list46rhtml'
  /var/lib/gems/1.8/gems/actionpack-2.3.3/lib/action_view/renderable.rb:34:in 'send'
  /var/lib/gems/1.8/gems/actionpack-2.3.3/lib/action_view/renderable.rb:34:in 'render'
  /var/lib/gems/1.8/gems/actionpack-2.3.3/lib/action_view/base.rb:301:in 'with_template'
  /var/lib/gems/1.8/gems/actionpack-2.3.3/lib/action_view/renderable.rb:30:in 'render'
  /var/lib/gems/1.8/gems/actionpack-2.3.3/lib/action_view/template.rb:199:in 'render_template'
  /var/lib/gems/1.8/gems/actionpack-2.3.3/lib/action_view/base.rb:260:in 'render'
  /var/lib/gems/1.8/gems/actionpack-2.3.3/lib/action_view/base.rb:343:in '_render_with_layout'
  /var/lib/gems/1.8/gems/actionpack-2.3.3/lib/action_view/base.rb:257:in 'render'
  /var/lib/gems/1.8/gems/actionpack-2.3.3/lib/action_controller/base.rb:1246:in 'render_for_file'
  /var/lib/gems/1.8/gems/actionpack-2.3.3/lib/action_controller/base.rb:941:in 'render_without_benchmark'
  /var/lib/gems/1.8/gems/actionpack-2.3.3/lib/action_controller/benchmarking.rb:51:in 'render'
  /var/lib/gems/1.8/gems/activesupport-2.3.3/lib/active_support/core_ext/benchmark.rb:17:in 'ms'
  /usr/lib/ruby/1.8/benchmark.rb:308:in 'realtime'
  /var/lib/gems/1.8/gems/activesupport-2.3.3/lib/active_support/core_ext/benchmark.rb:17:in 'ms'
  /var/lib/gems/1.8/gems/actionpack-2.3.3/lib/action_controller/benchmarking.rb:51:in 'render'
  /var/lib/gems/1.8/gems/actionpack-2.3.3/lib/action_controller/base.rb:1322:in 'default_render'
  /var/lib/gems/1.8/gems/actionpack-2.3.3/lib/action_controller/base.rb:1328:in 'perform_action_without_filters'
  /var/lib/gems/1.8/gems/actionpack-2.3.3/lib/action_controller/filters.rb:617:in 'call_filters'
  /var/lib/gems/1.8/gems/actionpack-2.3.3/lib/action_controller/filters.rb:610:in 'perform_action_without_benchmark'
  /var/lib/gems/1.8/gems/actionpack-2.3.3/lib/action_controller/benchmarking.rb:68:in 'perform_action_without_rescue'
  /var/lib/gems/1.8/gems/activesupport-2.3.3/lib/active_support/core_ext/benchmark.rb:17:in 'ms'
  /usr/lib/ruby/1.8/benchmark.rb:308:in 'realtime'
  /var/lib/gems/1.8/gems/activesupport-2.3.3/lib/active_support/core_ext/benchmark.rb:17:in 'ms'
  /var/lib/gems/1.8/gems/actionpack-2.3.3/lib/action_controller/benchmarking.rb:68:in 'perform_action_without_rescue'
  /var/lib/gems/1.8/gems/actionpack-2.3.3/lib/action_controller/rescue.rb:160:in 'perform_action_without_flash'
  /var/lib/gems/1.8/gems/actionpack-2.3.3/lib/action_controller/flash.rb:146:in 'perform_action'
  /var/lib/gems/1.8/gems/actionpack-2.3.3/lib/action_controller/base.rb:527:in 'send'
  /var/lib/gems/1.8/gems/actionpack-2.3.3/lib/action_controller/base.rb:527:in 'process_without_filters'
  /var/lib/gems/1.8/gems/actionpack-2.3.3/lib/action_controller/filters.rb:606:in 'process'
  /var/lib/gems/1.8/gems/actionpack-2.3.3/lib/action_controller/base.rb:391:in 'process'
  /var/lib/gems/1.8/gems/actionpack-2.3.3/lib/action_controller/base.rb:386:in 'call'
  /var/lib/gems/1.8/gems/actionpack-2.3.3/lib/action_controller/routing/route_set.rb:434:in 'call'
  /var/lib/gems/1.8/gems/actionpack-2.3.3/lib/action_controller/dispatcher.rb:88:in 'dispatch'
  /var/lib/gems/1.8/gems/actionpack-2.3.3/lib/action_controller/dispatcher.rb:111:in '_call'
  /var/lib/gems/1.8/gems/actionpack-2.3.3/lib/action_controller/dispatcher.rb:82:in 'initialize'
  /var/lib/gems/1.8/gems/activerecord-2.3.3/lib/active_record/query_cache.rb:29:in 'call'
  /var/lib/gems/1.8/gems/activerecord-2.3.3/lib/active_record/query_cache.rb:29:in 'call'
  /var/lib/gems/1.8/gems/activerecord-2.3.3/lib/active_record/connection_adapters/abstract/query_cache.rb:34:in 'cache'
  /var/lib/gems/1.8/gems/activerecord-2.3.3/lib/active_record/query_cache.rb:9:in 'cache'
  /var/lib/gems/1.8/gems/activerecord-2.3.3/lib/active_record/query_cache.rb:28:in 'call'
  /var/lib/gems/1.8/gems/activerecord-2.3.3/lib/active_record/connection_adapter /abstract/connection_pool.rb:361:in 'call'
  /var/lib/gems/1.8/gems/rack-1.0.0/lib/rack/head.rb:9:in 'call'
  /var/lib/gems/1.8/gems/rack-1.0.0/lib/rack/methodoverride.rb:24:in 'call'
  /var/lib/gems/1.8/gems/actionpack-2.3.3/lib/action_controller/params_parser.rb:15:in 'call'
  /var/lib/gems/1.8/gems/actionpack-2.3.3/lib/action_controller/session/cookie_store.rb:93:in 'call'
  /var/lib/gems/1.8/gems/actionpack-2.3.3/lib/action_controller/reloader.rb:29:in 'call'
  /var/lib/gems/1.8/gems/actionpack-2.3.3/lib/action_controller/failsafe.rb:26:in 'call'
  /var/lib/gems/1.8/gems/rack-1.0.0/lib/rack/lock.rb:11:in 'call'
  /var/lib/gems/1.8/gems/rack-1.0.0/lib/rack/lock.rb:11:in 'synchronize'
  /var/lib/gems/1.8/gems/rack-1.0.0/lib/rack/lock.rb:11:in 'call'
  /var/lib/gems/1.8/gems/actionpack-2.3.3/lib/action_controller/dispatcher.rb:106:in 'call'
  /var/lib/gems/1.8/gems/rails-2.3.3/lib/rails/rack/static.rb:31:in 'call'
  /var/lib/gems/1.8/gems/rack-1.0.0/lib/rack/urlmap.rb:46:in 'call'
  /var/lib/gems/1.8/gems/rack-1.0.0/lib/rack/urlmap.rb:40:in 'each'
  /var/lib/gems/1.8/gems/rack-1.0.0/lib/rack/urlmap.rb:40:in 'call'
  /var/lib/gems/1.8/gems/rails-2.3.3/lib/rails/rack/log_tailer.rb:17:in 'call'
  /var/lib/gems/1.8/gems/rack-1.0.0/lib/rack/content_length.rb:13:in 'call'
  /var/lib/gems/1.8/gems/rack-1.0.0/lib/rack/chunked.rb:15:in 'call'
  /var/lib/gems/1.8/gems/rack-1.0.0/lib/rack/handler/mongrel.rb:61:in 'process'
  /var/lib/gems/1.8/gems/mongrel-1.1.5/lib/mongrel.rb:159:in 'process_client'
  /var/lib/gems/1.8/gems/mongrel-1.1.5/lib/mongrel.rb:158:in 'each'
  /var/lib/gems/1.8/gems/mongrel-1.1.5/lib/mongrel.rb:158:in 'process_client'
  /var/lib/gems/1.8/gems/mongrel-1.1.5/lib/mongrel.rb:285:in 'run'
  /var/lib/gems/1.8/gems/mongrel-1.1.5/lib/mongrel.rb:285:in 'initialize'
  /var/lib/gems/1.8/gems/mongrel-1.1.5/lib/mongrel.rb:285:in 'new'
  /var/lib/gems/1.8/gems/mongrel-1.1.5/lib/mongrel.rb:285:in 'run'
  /var/lib/gems/1.8/gems/mongrel-1.1.5/lib/mongrel.rb:268:in 'initialize'
  /var/lib/gems/1.8/gems/mongrel-1.1.5/lib/mongrel.rb:268:in 'new'
  /var/lib/gems/1.8/gems/mongrel-1.1.5/lib/mongrel.rb:268:in 'run'
  /var/lib/gems/1.8/gems/rack-1.0.0/lib/rack/handler/mongrel.rb:34:in 'run'
  /var/lib/gems/1.8/gems/rails-2.3.3/lib/commands/server.rb:111
  /usr/lib/ruby/1.8/rubygems/custom_require.rb:31:in 'gem_original_require'
  /usr/lib/ruby/1.8/rubygems/custom_require.rb:31:in 'require'
  script/server:3
  </code></pre>