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 nil.name
Extracted source (around line #13):
10: <% for driver in @driver %>
11:   <tr>
12:     <td><%=h driver.name %></td>
13:     <td><%=h driver.product_line.name %></td>
14:     <td><%= link_to ''Edit'', {:action =>
''driver_edit''} %>
15:     	<%= link_to ''Destroy'', {:action =>
''driver_delete'',:id =>
driver.id} %>
16:     </td>
###
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 }
    end
end
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---
What''s interesting is that I''ve done almost entirely the same
thing
with another view, and it works;
###### View
<% for driver in @drivers %>
  <tr>
    <td><%= driver.name %></td><td>
    	<%= driver.product_line.name %>
    </td>
  </tr>
<% end %>
###### Controller
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.html
      format.xml  { render :xml => @drivers }
    end
  end
end
On Jan 12, 1:35 am, deadSkip
<richard.sevi...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
wrote:> 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 nil.name
> Extracted source (around line #13):
>
> 10: <% for driver in @driver %>
> 11:   <tr>
> 12:     <td><%=h driver.name %></td>
> 13:     <td><%=h driver.product_line.name %></td>
> 14:     <td><%= link_to ''Edit'', {:action =>
''driver_edit''} %>
> 15:             <%= link_to ''Destroy'', {:action =>
''driver_delete'',:id =>
> driver.id} %>
> 16:     </td>
>
> ###
>
> 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 }
>     end
> end
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk-unsubscribe@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---
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. On Jan 12, 1:35 am, deadSkip <richard.sevi...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> 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 nil.name > Extracted source (around line #13): > > 10: <% for driver in @driver %> > 11: <tr> > 12: <td><%=h driver.name %></td> > 13: <td><%=h driver.product_line.name %></td> > 14: <td><%= link_to ''Edit'', {:action => ''driver_edit''} %> > 15: <%= link_to ''Destroy'', {:action => ''driver_delete'',:id => > driver.id} %> > 16: </td> > > ### > > 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 } > end > end--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---