added flash[:error] and model validations