If separate actions are brought on the debt and to foreclose the mortgage given to secure it, the plaintiff shall elect which to prosecute and the other shall be dismissed.