In an action against several heirs jointly or several devisees jointly, the amount which the plaintiff recovers must be apportioned among all the heirs of the ancestor or devisees of the testator in proportion to the value of the real property descended or devised, and such proportion only can be recovered of each heir or devisee.