An emergency ordinance is an ordinance necessary for the immediate preservation of the public peace, health, morals, safety or welfare in which the emergency is defined and declared in a preamble thereto, and is adopted by majority vote of those present. No prosecution shall be based upon provisions of an emergency ordinance until twenty-four hours after the ordinance has been filed with the City Administrator and posted in three conspicuous places or until the ordinance has been once published in the official newspaper, unless the person charged with violation had actual notice of the adoption of the ordinance prior to the act or omission complained of.