It was just father and son out there on the prairie, working the ranch. The town knew the dad as a model citizen, ready to step in at any hint of trouble to keep the peace. The son minded his manners and performed his daily chores without complaint. This was “The Rifleman,” which aired from 1958 to 1963.

I watched the black-and-white Western as a boy and watch it now, in reruns, as a grandfather. Chuck Connors played the father, Lucas McCain, a Civil War veteran who promises his dying wife to care for their son. Set in the 1880s, it was the first prime-time TV series featuring a single parent raising a child.

TV in the 1960s was big on fathers. You could watch Jim Anderson on “Father Knows Best,” Danny Williams on “Make Room For Daddy,” Steve Douglas on “My Three Sons,” Ward Cleaver on “Leave It to Beaver,” Ben Cartwright on “Bonanza,” Rob Petrie on “The Dick Van Dyke Show,” Ozzie Nelson on “The Adventures of Ozzie and Harriet,” Tom Corbett on “The Courtship of Eddie’s Father” and Andy Taylor on “The Andy Griffith Show.”

Generally these were suburban dads, breadwinners who carried briefcases to work while the wife stayed home raising the kids. They reflected a largely patriarchal society where men made the big decisions and tended to play the role of fathers only while off-duty.

Somewhere along the line, fathers on TV came to be redefined mainly as hapless fools. Starting in the 1980s, “Married With Children” gave us the lowlife Al Bundy, who treated everyone — including his wife, daughter and son — with equal disdain.

“The Simpsons” brought us Homer Simpson, a cartoon character who, love him though I do, is defined mostly by chronic stupidity, pathological gluttony and boozing — and, on the whole, his utter indifference to his family, his job and his community. This trend accelerated with the likes of Frank Costanza on “Seinfeld” and Reginald Foreman on “That ’70s Show.”

Almost certainly this metamorphosis came about as a response to the rising demands of feminism, the economic forces squeezing the middle class and the emergence of the two-income family. Men no longer had all the answers. The Boomer Dad went bust.

“The Rifleman” was different. Lucas McCain knew the Bible and sought to live a virtuous life. He could cock his Winchester one-handed and hit anything that blinked. But he resorted to violence to stop the bad guys only after all efforts at reason and diplomatic persuasion failed.

Every episode played as a parable, depicting the divide between right and wrong. Justice always prevailed.

Above all, McCain cared for his son, Mark, played by Johnny Crawford. He taught him to follow the golden rule and lead by example, treating everyone, friend and stranger alike, with respect, tolerance and empathy.

Living wifeless and motherless, they tried more than anything else to do right by each other.

True, TV in recent years has given us some dads we could readily admire, from Ray Barone on “Everybody Loves Raymond” to Jack Pearson on “This Is Us.” And I have certain favorites, such as Jack Arnold on “The Wonder Years,” Dan Conner on “Roseanne” and Martin Crane on “Frasier.”

The divorced Richard Castle on “Castle” is a model dad to the teenage daughter who lives with him. Hank Hill on the animated “King Of The Hill.” Even the mobbed-up Tony Soprano would clearly make any sacrifice for his son and daughter, though he rarely knew quite how.

Still, Lucas McCain gets my vote for best TV dad of all time. He was the kind of dad all dads should want to be.

My own father, back in the 1950s and ’60s, was far from a perfect dad — a good man but too busy on the job to pay much attention to his family. His father, in the 1930s and 1940s, was much the same. And I’m no exception.

But I’m still going to try to be a hero to my kids. Just because perfection as a father is unattainable is no excuse for us to stop trying to attain it. Like Lucas McCain, we just need to take aim.

Bob Brody, an executive and essayist in Forest Hills, is the author of the memoir “Playing Catch With Strangers: A Family Guy (Reluctantly) Comes Of Age.”