Last year I was at my wits' end with curbside organics recycling. A newbie composter, I dutifully discarded my melon rinds, coffee grounds, pizza boxes and other food waste into a shiny new plastic cart provided by my first-ring suburb.

I might as well have set out a blinking neon sign for the wildlife in my neighborhood announcing the hottest new all-you-can-eat buffet.

Squirrels gnawed their way through the bin's lid, leaving plastic orange confetti all over my driveway. Raccoons, on the other hand, simply lifted the lid and chowed down on leftovers, leaving a disgusting mess in their wake. I started placing a brick on top of the lid to deter them. But the raccoons just brushed the brick aside, or pulled down the cart with such a ruckus that it woke my sleeping kids.

Then came the summer infestation. After baking in the heat for days, the soupy, stinky kitchen scraps became a magnet for flies and — this is so gross! — maggots.

One person who felt my pain was journalist Amy Dempsey of the Toronto Star. She wrote a 5,700-word investigation into Toronto's efforts to distribute a "raccoon-resistant" compost bin. Launched in 2016, the bins had a locking mechanism that the mayor heralded as a special weapon in the fight against the city's legendarily clever raccoons.

"Defeat is not an option," he told reporters at the time.

But after the rollout, Dempsey's bin was being raided by the trash — er, organic waste — bandits. Video footage caught the nocturnal pilferers tipping the bin over, which made the lock's handle easier to turn.

"I think every solution humans come up with over time will be solved by these creatures. They're just too clever," she said.

Dempsey's solution? She threaded a bungee cord through the hinges of all of her waste and recycling bins. Once connected, the bins collectively were too heavy for the raccoons to knock down.

Hopefully, the critters in your community aren't as cunning. But more Minnesotans are finding out. Minneapolis started to roll out its residential curbside organics collection program in 2015, and surrounding communities have since caught on. Hennepin County required all of its cities to offer organics recycling by 2022, and about 95,000 households now participate. Ramsey County and Washington County are planning to expand their joint food scraps pickup pilot program.

Some 25-40% of our garbage is filled with things that can be composted. That waste takes up space in landfills, where it decomposes without oxygen and creates methane gas, which contributes to climate change. Composting facilities, which aerate and turn the food waste, help reduce greenhouse gases while generating nutrient-rich soil that we desperately need.

Despite my early frustrations, I'm squarely on Team Composting. Organics recycling is something everyone can and should partake in. Have I outsmarted my unwelcome dinner guests once and for all? I wouldn't go that far, but I've finally established a solid system after some trial and error and advice from the pros:

On maggots

"Everyone will eventually get maggots — it's going to happen," says Kellie Kish, chair of the Minnesota Composting Council and recycling coordinator for the city of Minneapolis. "The No. 1 thing I tell people is they were already in the garbage cart. They may even be in your recycling cart."

The simplest hack is to prop open the lid for a couple of hours.

"Once light can get into the container, the little buggers are going to worm their way up the sides of the bins, and the neighborhood birds will come and eat them," Kish says. "It's amazing. You didn't have to deal with getting them out of there; the birds got a nice, healthy and nutritious treat; and the maggots didn't turn into flies. It's like a triple-win."

Freeze your food scraps

Place your bags of organics waste in the freezer, and take them out to the collection bin the night before pickup to limit exposure. This tip, shared to me by waste reduction specialist Nancy Lo of Hennepin County, was a game-changer: I haven't had any messes or maggots this summer.

If you don't have room in your freezer, you can prioritize freezing meat and dairy waste, which is especially attractive to flies.

Clean your cart

Give it a simple rinse with water, or a mix of vinegar and water, says Ben Knudson, also of Hennepin County. Keep the lid open for a couple hours when your cart is empty to let it dry out. Salt or vinegar may prevent insect larvae from hatching.

Some companies also offer mobile bin-cleaning services; make sure that the soap they use does not contain chemicals that could pollute storm drains and ultimately our waterways, Kish advises.

Seal the lid

To further protect your cart from rodents, use a bungee cord to keep the lid closed throughout the week. Unlatch the cord the night before pickup so your collection crew can empty the bin. You can also try weighing down the lid with a cinder block, brick or sandbag.

Inside the home

As your food scraps break down, they generate moisture. Your kitchen container should have a vented lid, which will allow the moisture to evaporate. Ventilation will slow the decomposition process and help prevent the waste from turning into a foul, soupy mess. Experiment with different kinds of compostable bags until you find one that works for you.

Make it extra spicy

Squirrels detest spice, as I noted in a previous column about protecting your porch pumpkins from these ravenous rodents. Spray down your cart with water mixed with cayenne pepper and a dash of vegetable oil and dish soap. You'll need to reapply after a rain.

Deterring raccoons

Raccoons can be deterred by spraying your cart with ammonia.

Also, be sure to inspect the area around your house for hiding holes that might invite raccoons. They might set up shop under your deck or in an old shed, for example. Cover up holes with chicken wire, suggests Dempsey.

Even though Dempsey wrote at length about the raccoon problem in Toronto, she believes they belong just as much as she does, and it was rewarding to find a composting solution that worked.

"My No. 1 priority is to be the best environmental citizen I can be without going crazy," she says. "Is composting glamorous? No. But I do it because it's a good and right thing to do for the environment, and to be part of the city and community I live in."

Defeat, after all, is not an option.