Why count require to check project member present or not? you can check @project.project_members.present?