The trip to the supermarket and back home covers 5+5=<<5+5=10>>10 miles.
The round trip of two miles each before he actually went to the farm covers 2+2=<<2+2=4>>4 miles.
Six miles to the farm and the total mileage is 10+4+6=<<10+4+6=20>>20 miles.
The truck consumed 12-2=<<12-2=10>>10 gallons of gasoline for the total journey.
So, the rate is 20/10= <<20/10=2>>2 miles per gallon.
#### 2