Maymun bin Mihran said: Whenever a case came before Sayyiduna Abu Bakr (may Allah be pleased with him), he would look into the Book of Allah. If it was found in the Book of Allah, he would judge by it. If he did not find it in the Book of Allah, he would look into the Sunnah of the Prophet (peace and blessings be upon him). If he knew it, he would judge according to it. If he did not know, he would go out to the Muslims and say: Such-and-such a case has come to me; I found nothing in the Book of Allah or the Sunnah of the Messenger. Do you know of the Prophet (peace and blessings be upon him) having given any judgement concerning it? Sometimes a group would go to him and say: Yes, such-and-such a judgement was given concerning it. Then he would judge in accordance with the judgement of the Messenger of Allah (peace and blessings be upon him).
Ja'far said: Someone other than Maymun narrated that Sayyiduna Abu Bakr (may Allah be pleased with him) would say at that time: All praise is for Allah, who has granted that some among us preserve the sayings of His Prophet (peace and blessings be upon him). If no one remembered, he would summon the people before him and consult the scholars and others. If their opinion was agreed upon, he would judge accordingly.
(b) Ja'far said: Maymun narrated that Sayyiduna Umar bin al-Khattab (may Allah be pleased with him) also used to do the same. If he found its basis in the Qur'an and Sunnah, well and good; otherwise he would look at the judgements of Abu Bakr al-Siddiq (may Allah be pleased with him). If he found a judgement, he would judge accordingly; otherwise he would consult the leaders and scholars of the Muslims and judge accordingly.
Hadith Referenceالسنن الكبرى للبيهقي / كتاب آداب القاضي / 20341