Whenever the plaintiff in an action, or in a garnishment or other proceeding is a nonresident of the county or begins such action or proceeding as the assignee of some other person, or of a firm or corporation, as to all causes of action sued upon, the justice may require of him or her security for the costs in the action or proceeding in a sum not exceeding fifty dollars, at the time of the commencement of the action, and after an action or proceeding has been commenced by such nonresident or assignee plaintiff, the defendant or garnishee defendant may require such security by motion; and all proceedings shall be stayed until such security has been given.