Issue with book.publisher.name p105

0 views
Skip to first unread message

mole1066

unread,
Aug 7, 2008, 1:48:47 PM8/7/08
to Beginning Ruby on Rails E-Commerce
On page 107 there is a method to display data from an external table

Although all my other database functions work fine this does not and i
get the following error:

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

If I replace the command to use a local table all is fine, it is just
when connecting through the foreign key

Any clues as to why this may be occurring? I am using rails v2.1.0 and
mysql 5.0.5


Jarkko Laine

unread,
Aug 12, 2008, 12:11:27 AM8/12/08
to railsec...@googlegroups.com

That specific book doesn't have a publisher?

//jarkko

--
Jarkko Laine
http://jlaine.net
http://dotherightthing.com
http://www.railsecommerce.com
http://odesign.fi


mole1066

unread,
Aug 12, 2008, 2:10:56 AM8/12/08
to Beginning Ruby on Rails E-Commerce
It was actually to do with a slightly different project I was working
on. Because I hadn't used exactly the same column names, especially
for the foreign key. I therefore had to specify the name of the
foreign key in the belongs_to statement in the model

cheers
Michael
Reply all
Reply to author
Forward
0 new messages