"Totally disconnected" analogue of a classical result from functional analysis 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.
 A: Let $R = \mathscr C^{\infty}(X)$.   The argument here carries over identically to show that every ideal of $R$ is contained in a maximal ideal of the form $\mathfrak p = \{ f \in R : f(x) = 0\}$ for some $x \in X$.  So we just need to show that no such prime $\mathfrak p$ contains a proper prime ideal.  This is the same as saying that $R_{\mathfrak p}$ is a zero dimensional local ring, i.e. every element of $\mathfrak p R_{\mathfrak p}$ is nilpotent.  
But since $R$ is reduced, so is $R_{\mathfrak p}$, so this is equivalent to saying that $\mathfrak p R_{\mathfrak p} = 0$, i.e. $R_{\mathfrak p}$ is a field.  It suffices to show that the image of $\mathfrak p$ in $R_{\mathfrak p}$ is zero, i.e. if $f \in \mathfrak p$, then there exists an $h \in R - \mathfrak p$ such that $fh = 0$.  
Since $f \in \mathfrak p$ and locally constant, it is zero in a compact open neighborhood $V$ of $x$.  The complement of this compact neighborhood is also open, and one can take $h$ to be nonzero on $V$, and zero on the complement of $V$.  
A: 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".)
