
    William A. PROUTY, and Cheryl Prouty, a minor, by William A. Prouty, her father and next friend, Appellants, v. CLAYTON COUNTY, Iowa, Clayton County Iowa Board of Supervisors, Gerald Stence, Kermit Klinge and Charles Meyers, as Members of the Clayton County, Iowa Board of Supervisors, and Clayton County, Iowa Engineer, Milton Johnson, Appellees.
    No. 60395.
    Supreme Court of Iowa.
    April 19, 1978.
    
      Mark D. Buchheit, West Union, for appellants.
    Harold H. Pahlas, County Atty., and Kevin H. Clefisch, Asst. County Atty., for ap-pellees.
    Considered by MOORE, C. J., and MASON, UHLENHOPP, REYNOLDSON and McCORMICK, JJ.
   MOORE, Chief Justice.

This case arises from defendant County’s alleged failure to maintain a road, eight-tenths of a mile long, that runs adjacent to property owned and resided upon by plaintiffs. Trial court dismissed plaintiffs’ damage and mandamus action whereby they sought to compel county maintenance of the road. We reverse and remand for further proceedings.

On November 20, 1975, plaintiffs commenced the present action'in Clayton County District Court alleging that defendants, in contravention of their legal duties, had failed to maintain the road. Plaintiffs further alleged the condition of the road was so dilapidated that it interfered with the access to their properties to a substantial degree. They prayed that a writ of mandamus issue ordering defendants to “take all appropriate steps” to repair the road and for damages in the amount of $3100.

After defendants answered denying the material allegations of the petition, plaintiffs amended their petition claiming defendants had deposited materials, including trees, on plaintiffs’ private lane and raised the prayer to $6100 for damages incurred subsequent to the original filing. Defendants filed a timely answer to the amendment.

Over two and one-half years later (no discovery was ever initiated) defendants filed a motion for summary judgment asserting mandamus was not the appropriate remedy to compel an exercise of their discretion. The motion was supported by affidavits wherein the county engineer and one board member stated the road was maintained in the same manner as similar roads in the county.

Plaintiffs filed a resistance supported by counter-affidavits in which plaintiff William Prouty and his brother stated the road was not properly maintained.

After hearing on defendants’ motion for summary judgment the trial court ruled:

“ * * *. The Motion for Summary Judgment of the Defendants is not the proper remedy to reach the verdict, which the Defendants desire, so that the Court, of necessity is going to deny the request for Motion For Summary Judgment; however, in order to properly determine this case once and for all, the Court is going to treat the Motion for Summary Judgment as a Motion To Dismiss, and this cause is hereby dismissed for failure of the Plaintiffs to state a cause of action, and this cause is hereby dismissed at Plaintiffs’ costs.”

Plaintiffs have appealed from the court’s sua sponte order treating defendants’ motion for summary judgment as a motion to dismiss and dismissal of their petition on the ground it failed to state a cause of action. Defendants have not cross-appealed.

I. The general rule is that the moving party is confined to the relief asked for in his motion, or specified in the notice of hearing. 60 C.J.S. Motions and Orders § 39b, page 56; State v. Weger, Iowa, 211 N.W.2d 322, 323-324.

II. Assuming, arguendo, defendants’ motion was a motion to dismiss on the ground the petition failed to state a cause of action, the court was precluded from ruling on it by the provisions of rule 85(a) Rules of Civil Procedure, which provides:

“(a) Motions. Motions attacking a pleading must be served before responding to a pleading or, if no responsive pleading is required by these rules, upon motion made by a party within twenty days after the service of the pleading on such party.”

Here defendants’ answers to plaintiffs’ petition and amendments were filed months before their motion.

III. Overruling or sustaining a motion to dismiss does not depend upon trial court’s discretion. It must rest on legal grounds and is subject to review by this court. The motion is a waiver of any ambiguity or uncertainty in the pleadings. Such a motion grounded on failure to state a cause of action is sustainable only when it appears to a certainty the pleader has failed to state a claim upon which any relief may be granted under any state of facts which could be proved in support of the claim asserted. In making this determination the pleading should be construed in the light most favorable to the pleader with doubts resolved in his favor and the challenged allegations accepted as true. Weber v. Madison, Iowa, 251 N.W.2d 523, 525 and citations.

IV. With these principles in mind we find plaintiffs’ petitions and amendments sufficiently plead a cause of action for mandamus under our holding in Charles Gabus Ford v. Iowa St. Highway Com’n., Iowa, 224 N.W.2d 639. Additionally plaintiffs’ petition as amended clearly plead tor-tious actions by defendants and resulting damages. See Conrad v. Board of Supervisors of Lee County, Iowa, 199 N.W.2d 139, 144, and citations.

We hold the trial court committed reversible error in dismissing plaintiffs’ cause of action and entering judgment against them for costs. Therefore, this case must be remanded to the lower court for further proceedings.

REVERSED AND REMANDED.  