Handle undefined method assigned_to for nil:NilClass