Newbie Question - Nil Error in ActiveController

Hi everyone, looking for some help with this error below. It seems
that althought it finds the product_line_id attribute, the code
doesn’t find the product_line’s name attribute. I’ve already declared
the has_many: call_driver relationship in the product_line model, and
the belongs_to: product_line relationship in the call_driver model.

It also works in the console, oddly enough, but not in the view.

I know I’m missing something elemental here, but I haven’t the
faintest clue what it is.

NoMethodError in Admin#index

Showing admin/index.html.erb where line #13 raised:

You have a nil object when you didn’t expect it!
The error occurred while evaluating
Extracted source (around line #13):

10: <% for driver in @driver %>

12: <%=h %>
13: <%=h %>
14: <%= link_to ‘Edit’, {:action => ‘driver_edit’} %>
15: <%= link_to ‘Destroy’, {:action => ‘driver_delete’,:id =>} %>

admin_controller has this for the index action;

def index
@driver = CallDriver.find(:all)

respond_to do |format|
  format.html # index.html.erb
  format.xml  { render :xml => @driver }


What’s interesting is that I’ve done almost entirely the same thing
with another view, and it works;


<% for driver in @drivers %>

<%= %> <%= %> <% end %>

class ShowController < ApplicationController
def show_drivers

Find Call Drivers

@drivers =
CallDriver.find(:all, :conditions => [
‘product_line_id = :product_line and
sub_product_line_id = :sub_product_line and
platform_id = :platform and
consolidation_id = :consolidation and
segment_id = :segment’,
{:product_line => params[:product_line],
:sub_product_line => params[:sub_product_line],
:platform => params[:platform],
:consolidation => params[:consolidation],
:segment => params[:segment]}])
respond_to do |format|
format.xml { render :xml => @drivers }

Please disregard, I’ve discovered the problem. I’m an idiot and forgot
that some of my data didn’t have a product_line_id set.