On 25 February 2011 19:28, John Merlino <li...@ruby-forum.com> wrote: > post.blog_images.first.image_file_name > > outputs > > undefined method `image_file_name' for nil:NilClass
That means that in your chain of method calls, the thing before "image_file_name" is nil. So there is no "first" record in the blog_images collection... are you sure you have some associated images? I tend to find using a "guard" helps in chained calls like this: post.blog_images.first.image_file_name if post.blog_images.first or even (when necessary) foo.bar.baz.method_name if foo.bar && foo.bar.baz -- 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 this group at http://groups.google.com/group/rubyonrails-talk?hl=en.