Consider the following result:
Let $X$ be a compact Hausdorff space. Then $x \mapsto \mathfrak m_x = \{ f \in \mathscr C(X) : f(x) = 0 \}$ defines a bijection $X \rightarrow \operatorname{m-spec} \mathscr C(X)$, where $\mathscr C(X)$ is the ring of continuous functions $X \rightarrow \mathbb C$.
See for example my previous answer here. There is an interesting analogue of these statement which I have seen mentioned in a number-theoretic context:
Let $X$ be a compact totally disconnected Hausdorff space. Then $x \mapsto \mathfrak p_x = \{ f \in \mathscr C^{\infty}(X) : f(x) = 0 \}$ defines a bijection of sets $X \rightarrow \operatorname{spec} \mathscr C^{\infty}(X)$, where $\mathscr C^{\infty}(X)$ is the ring of locally constant functions $X \rightarrow \mathbb Q$.
Is this result true? It seems strange that $\mathscr C^{\infty}(X)$ should have no nonmaximal prime ideals.
This is indeed true. Let me provide a bit more context for this result. First of all, it remains true with $\mathbb{Q}$ replaced by any field $K$. To prove this, it suffices by your argument to prove that any prime ideal is contained in $\mathfrak{p}_x$ for some $x$. If $I$ is an ideal which is not contained in any $\mathfrak{p}_x$, choose functions $f_x\in I$ for each $x$ such that $f_x(x)\neq 0$. Let $U_x$ be the support of $f_x$, which is not just closed but clopen because $f_x$ is locally constant. By compactness, finitely many of the $U_x$ cover $X$, say $U_{x_1},\dots U_{x_n}$. We may furthermore shrink these sets to clopen sets $V_{1},\dots,V_{n}$ which are disjoint and cover $X$ (let $V_{i}=U_{x_i}\setminus\bigcup_{j<i}U_{x_j}$). Then $1_{V_i}$ is a multiple of $f_{x_i}$ (multiply by a function which is $1/f_{x_i}$ on $V_i$ and $0$ elsewhere), and so $1=\sum_i 1_{V_i}\in I$.
Also, the map $f:X \rightarrow \operatorname{Spec} \mathscr C^{\infty}(X)$ is not just a bijection but a homeomorphism. This follows from the fact clopen sets generate the topology of $X$ and the image of a clopen set is clopen (by considering characteristic functions of clopen sets and the open subsets of $\operatorname{Spec} \mathscr C^{\infty}(X)$ they define).
It is customary to consider this result primarily in the case $K=\mathbb{F}_2$. In that case, the ring $B$ of locally constant functions $X\to K$ can be identified with the Boolean algebra of clopen subsets of $X$ (identify a clopen subset with its characteristic function). The theorem that the natural map $X\to\operatorname{Spec} B$ is a homeomorphism is then part of Stone duality, an equivalence of categories between the category of totally disconnected compact Hausdorff spaces and the category of Boolean algebras.
(In fact, this equivalence of categories holds more generally over any field $K$, if you replace "Boolean algebras" with "$K$-algebras generated by idempotents".)