Protect against “NoMethodError: undefined method `compact' for nil:NilClass”