> Also you have not said what happens if you include the test checking
> for no blog_images.
>
> Colin
I think I realized what the problem was. There were four records in the 
blog_posts table. At the time of the post, I only had one record in 
blog_images table that linked to first record of blog_posts. What this 
is doing:

post.blog_images.first.image_file_name

it is iterating for each post the first image_file_name linked to it. So 
the time it iterates through the second post, since there is not  an 
image_file_name associated with it, it throws the exception since the 
array object has no image_file_name method!

This was data error on my part. But adding that if is what made me 
realize it:

<img src="/images/<%= post.blog_images.first.image_file_name if 
post.blog_images.first %>" width="220" height="174" alt="" style="top: 
27px; left: 13px;" />

Thanks for all responses.

-- 
Posted via http://www.ruby-forum.com/.

-- 
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.

Reply via email to