While this other answer addresses this particular issue with donkeys, this answer has complementary information should you be considering an animal not normally available to Rangers.
The Ranger's animal companion list is very restrictive, contrary to the Druid or Hunter lists which allow all companions. And unless your GM allows otherwise, you gotta pick one animal from that short list:
A Ranger who selects an animal companion can choose from the following list: badger, bird, camel, cat (small), dire rat, dog, horse, pony, snake (viper or constrictor), or wolf. If the campaign takes place wholly or partly in an aquatic environment, the ranger may choose a shark instead.
That said, you need to take an ability that allows you to pick animals from the Druid's or Hunter's list of animal companions like the Beastmaster archetype. Regardless, none will be available if you are using only the Core Rulebook.
east master forms a close bond with an animal companion. This ability functions like the druid animal companion ability (...). Unlike a normal ranger, a beast master’s choice of animal companion is not limited to a subset of all possible animal companion choices—he may choose freely among all animal companion choices, just as a druid can.
That said, it's not uncommon for GMs to make exceptions on that ruling. I once allowed our Ranger to take a giant ant on a desert-themed campaign, for instance.