@preComments = Comment.where(:resource_hash => resource_hash).sort(:created_at.desc).all
@preComments.each do |comment|
u = ::User.find_by_id comment.user_id
p u
@comments << @preComments
p "HERE!!!!!"
end
That's my code, but @comments isn't defined so I get an error:
You have a nil object when you didn't expect it! You might have expected an instance of Array. The error occurred while evaluating nil.<<
If I create an array first, then my view can't read it. So how do I do this?
@preCommentsvs@comments, there might be a better way.