He made a second campaign to Córdoba Province, and after the defeat in the Battle of Oncativo fled to Buenos Aires with Facundo Quiroga.
Ramírez was appointed commander of the southern border of Mendoza, based in San Rafael, and the same year was badly injured in a fight against the Indians, just before there invasion caused the death of General and former governor José Albino Gutiérrez.
His court passed a sentence of death on Colonels Lorenzo Barcala and José Ignacio Correa de Saá.
He joined forces with General Ángel Pacheco, and led one of the wings of the federal cavalry in the Battle of Rodeo del Medio.
In March 1847, the Buenos Aires ambassador in Chile, Bernardo de Irigoyen, organized a revolution against Segura, and Ramírez confronted him with some success.