title: Rails - undefined method `name' for nil:NilClass
body: <p>Quick question. Here is my code:</p>
  
  <pre><code>#routes
  map.resources :customers, :has_many =&gt; [:addresses, :matchings]
  map.connect ":controller/:action/:id"
  
  #url path:
  http://127.0.0.1:3000/customers/index/3
  
  #customers controller
  def index
    @customer = Customer.find(params[:id])
  end
  
  #customers view/index.html.erb
  ...
  &lt;%= @customer.name %&gt;
  ...
  </code></pre>
  
  <p>Error: undefined method `name' for nil:NilClass.</p>
  
  <p>Here's my reasoning. The parameter :id is coming from my url path (i.e. we're looking for customer #3 in the above path). @customer should find that array easily, then @customer.name should produce the name, but apparently @customer is blank. Why?</p>
  
  <p>I assume the problem is that I'm not producing an array in my controller?</p>
  
  <p><b>------UPDATE------</b></p>
  
  <p>Hi Larry, thanks very much for the comments.</p>
  
  <p>What I mean by 'index' is actually a home page that customers will hit when they log in to the site. (I also have separate logins for other users like employers and they go to their own index). I'm currently using 'list' as a list of customers and 'show' for one individual... is there a better way?</p>
  
  <p>Second and MOST important: the logs are not giving me the answer to the fundamental problem, which is the inability to render the page.</p>
  
  <pre><code>Processing CustomersController#index (for 127.0.0.1 at 2010-05-16 16:56:19) [GET]
  Parameters: {"action"=&gt;"index", "id"=&gt;"10", "controller"=&gt;"customers"}
  ...
  [4;36;1mCustomer Load (2.0ms)[0m   [0;1mSELECT * FROM "customers" WHERE ("customers"."id" = 10) [0m
  [4;35;1mMatching Load (24.0ms)[0m   [0mSELECT * FROM "matchings" WHERE ("matchings".customer_id = 10) [0m
  Completed in 153ms (View: 18, DB: 26) | 200 OK [http://127.0.0.1/customers/index/10]
  </code></pre>
  
  <p><b>------UPDATE #2 (last!) ------</b></p>
  
  <p>I read through all of your comments and they have helped me not only make progress on my problem but also learn more about how the pieces fit together. For that, thanks everyone.</p>
  
  <p>Alex is right - my routes are not lining up how they need to. I created a new action in my customer controller called Home. This is the customer's home base when they log in (it doesn't display info about one customer so it probably shouldn't be show, and it isn't a list so shouldn't be index or list).</p>
  
  <pre><code>Rake routes # ...gives me a list of routes that does NOT include home. Why?
  </code></pre>
  
  <p>Second, if the route displayed has, for example:</p>
  
  <pre><code>:action =&gt; "home"
  /customers # (instead of what I need, '/customers/:id')
  </code></pre>
  
  <p>what do I have to do to change that route to accept an :id?</p>