what is the local variable pin
here ? in <%= image_tag pin.user.avatar.url(:thumb), class: "thumbsize" %>
and some of the pin has no user
so you gotavatar' for nil:NilClass
as pin.user
is nil
so make it
<%= image_tag pin.user.avatar.url(:thumb), class: "thumbsize" unless pin.user.nil? %>