Everyone wants to know about the rats. "You grow food in New York City? But what about the rats? Doesn't your garden attract rodents? Don't they eat your food?" When I first told my new neighbor that I planned on having a garden in the summer, this was his immediate reaction. Since his backyard is connected to mine, I absolutely understand his concern and appreciate that my garden can affect his yard, too.
A farm or garden anywhere--heck, a simple yard anywhere-- is going to have natural pests, whether it's deer out in the country or feral cats here in the city. So my short answer is, yes, there are rats sometimes, but no more than any other Brooklyn yard with or without a garden. The important thing is to garden responsibly so you don't attract more rats. Here are some tips to keep in mind:
Rats really don't like fruit or veggies. Although rats will eat anything if they have to, their dietary needs make them attracted to proteins, fats, fresh grains, and cooked foods. A fresh cucumber is not very appetizing or nourishing, and they will move on pretty quickly if that's all they find in your garden.
They look for food that is close to their home. So if they can't make a home in your garden, they probably won't dine there either. I grow my plants in large bins, not directly in the ground, so there's no earth for them to dig burrows into. Keep corners clear of junk and piles. THERE'S NOWHERE TO HIDE, RATTIES... (insert maniacal laughter)
They need water. Rats won't hang around somewhere that doesn't offer a daily water supply. Be sure to keep your rain barrel sealed, drain cleared, and fix your hose if it's leaky. Never water your garden at night so you don't leave puddles when they can't evaporate quickly.
NYC rats are terrible climbers. The species of rat found in our fine city is the Brown Rat, which for some odd reason has evolved to have no climbing or jumping abilities. If you garden in containers or tall raised beds, they couldn't even get to your plants if they tried.
Don't give them a free buffet. Clean up fallen or rotten garden food and keep all trash in a sealed barrel. Don't leave out food scraps after a BBQ. Don't leave out bird food, pet food, or pet poopies (rats love to eat dog poop! Seriously.) If you are composting, keep it in a sealed compost bin, and don't compost meat or dairy scraps that smell delightful and take forever to decompose.
If you have a problem with rats in your garden, do not, DO NOT put poison in your yard! Call a professional who has specialized traps that won't transfer poison to your plants. New York City is rightfully strict about how rat poison can be used, where you can put it, and what types are allowed-- here's an official pamphlet with more information.