The code starts with this:
publisher = Publisher.last
But the code after uses the variable p
if p in {authors: []}
puts "#{p.name} has no authors!"
end
It has to be publisher. The code examples after this also uses p as the variable. There is no exception. But the branching fails for the incorrect reason.