Hi All,

I'm working through o'reilly's "Up and Running" book, trying to build the photo gallery, but when i go to view a slide show i get this error

You have a nil object when you didn't expect it!
The error occurred while evaluating nil.filename

I assume it's a problem with the Slideshow model, and the relationships i have created.

I my slideshow.rb i have this
Code Ruby:
  has_many :photos, :through => :slides
  has_many :slides, :order => :position
i've created a slideshow helper to display the thumbnails and i think this is where the problem is. for some reason photo = nil
Code Ruby:
 def thumbnail_tag(slide)
    image_tag "photos/#{slide.photo.filename}"  if slide
  end

This is list method in my slideshow controller
Code Ruby:
 def list
    @slideshow_pages, @slideshows = paginate :slideshows, :per_page => 10
  end
Finally in list.rhtml file for listing all my slideshows i have this
Code Ruby:
<% for slideshow in @slideshows %>
	<div id="slideshow-summary">
		<div id="slideshow-caption">
			<%= slideshow.name %>
			<small>(<%= slideshow.slides.size %> slides)</small>
		</div>
		<div id="slideshow-thumbnails">
			<%= thumbnail_tag slideshow.slides[0] %>
			<%= thumbnail_tag slideshow.slides[1] %>
			<%= thumbnail_tag slideshow.slides[2] %>
			&nbsp;<strong>...</strong>
		</div>
		<div id="slideshow-controls">
    <%= link_to 'Play', :action => 'show', :id => slideshow %></td>
    <%= link_to 'Edit', :action => 'edit', :id => slideshow %></td>
    <%= link_to 'Destroy', { :action => 'destroy', :id => slideshow }, :confirm => 'Are you sure?' %>
 
		</div>
</div>
<% end %>


I can't figure out for the life of why this isn't working, and it's driving me nuts. Sorry for such a long post, but i'd appreciate any help.

I have Patrick's book too, and i think it's much better than the o'reilly one i have, but i just wanted to build a photo gallery instead of news sharing site.

Thanks,
John