On Sat, Jul 21, 2012 at 5:52 PM, James Harris <li...@ruby-forum.com> wrote: > In the console doing contact = Contact.find(1) finds my contact and the > contact.company.company_name returned the correct company name. > > Having contact.company.company_name in the index.html file returns an > error: > > undefined method `company_name' for nil:NilClass
Unstated assumption: in your "index" page you're doing something like <% @contacts.each |contact| do %> <%= contact.company.company_name %> <% end %> If not, no, of course not, "contact" isn't defined. Cargo-culting example code into your project isn't going to help; you need to think about what it's intended to do. -- Hassan Schroeder ------------------------ hassan.schroe...@gmail.com http://about.me/hassanschroeder twitter: @hassan -- 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@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.