Bart has a dream that he is at the school science fair presenting a Go-Go Ray. He zaps all the teachers, resulting in their dancing uncontrollably. Principal Skinner declares him the winner, but Bart wakes up realizing it was Lisa messing with him.
At breakfast, Lisa shows the family her science fair project, a steroid-enhanced tomato that she hopes will cure world hunger. Bart's project is to study the effects of cigarette smoking on dogs; his "volunteer" is Santa's Little Helper.
At the Springfield Nuclear Power Plant, Homer ducks out of work early and accompanies Barney on a tour of the Duff brewery. After the tour, Homer refuses to let the exceptionally drunk Barney drive home and forces him to hand over his keys. On their way out of the parking lot, their car is pulled over by Police Chief Wiggum, along with Eddie and Lou. They administer a breathalyzer test to Homer, which he fails. He is arrested, his license is revoked, and he must attend traffic school and Alcoholics Anonymous meetings.
At school, three days before the science fair, Lisa leaves her super tomato under Bart's care for a moment and he takes the opportunity to hurl it at Skinner while he is bent over tying his shoe. When Lisa sees what Bart has done with her project, she is furious. Lisa appeals to Marge for help, who suggests she run a hamster through a maze. Lisa takes the idea to heart, but instead of just testing the intelligence of a rodent, she pits a hamster against an unknowing Bart to find out who is smarter. After two simple tests, the hamster leads two to zero.
In bed, Marge gives Homer a magazine quiz about his drinking. Hearing his answers, she asks him to give up beer for a month, to which he agrees. Homer tries not to think about beer while he rides Lisa's bike to work. After a series of severe temptations, Homer crashes the bike as hundreds of bottles of Duff parachuted down on him from a blimp.
Bart later discovers Lisa's plans to humiliate him at the science fair and ruins them with a project of his own, "Can hamsters fly planes?". Lisa tries to reason that his project has no scientific merit, but everyone ignores her. A cute hamster sitting in the cockpit of a miniature plane wins over Skinner and he hands Bart the winning ribbon, much to Lisa's dismay.
At Homer's Alcoholics Anonymous meeting, he is kicked out by Reverend Lovejoy after confessing that his desperation for the taste of beer led him to "sneak into the football stadium and eat the dirt underneath the bleachers". But he exhibits more positive changes such as losing weight, saving over $100 and no longer sweating while he eats. After thirty days of sobriety, Homer rushes back to Moe's, despite Marge asking him to stay home. However, after seeing how alcohol has ruined the lives of Barney and the other barflies, he turns around and goes home. Homer and Marge ride a bike into the sunset.