Displaying 1 result from an estimated 1 matches for "get_first_imag".
Did you mean:
get_first_image
2006 Mar 03
5
avoiding nil object error?
...east one image assigned to
it. However, if a portfolio doesn''t have any images yet, the whole
thing falls apart and the app exits with the error:
"You have a nil object when you didn''t expect it!"
I tried to get around it by doing this in the portfolio model:
def get_first_image
self.images[0].image_url || "default.jpg"
end
and then in the partial:
<td class="col1"><img src="<%= portfolio_list.get_first_image -%>" /
></td>
but the exact same thing happens. If every portfolio has at least one
image it works well,...