Problems accessing relational objects

Dominic Son wrote:

<% @ads.each do |ad| %>
<%= ad.book.nil? %> (will say it's false, but yet...)
<%= ad.book.attributes %> (will give the following error:
<% end %>

"You have a nil object when you didn't expect it!
You might have expected an instance of ActiveRecord::Base.
The error occured while evaluating nil.attributes"

I would try looking at the objects with debug:
<%= debug ad %>
<%= debug ad.book %>

Dan Manges