Show $\mathbb{Z}_{(p)} [ \sqrt{D}]$ is a UFD 
Consider $\mathbb{Z}_{(p)} [ \sqrt{D}]$, for $D$ a squarefree integer, and $D \not\equiv 1 \bmod 4$. I want to show that this is a UFD. 

By considering $\mathbb{Z}_{(p)} [ \sqrt{D}] \cong (\mathbb{Z} - p\mathbb Z)^{-1}\mathbb{Z} [\sqrt{D}]$ I have computed the prime ideals of this ring, which are distinguished by the cases $p \mid D$, $ p \not \mid D$ but $D$ a square mod $p$, and $D$ is not a square mod $p$. 
However, I cannot seem to show that this is UFD, and I really don't quite know where to start. I was hoping I could do it by showing that $\mathbb{Z}[\sqrt{D}]$ is a UFD, but that turns out to be a very subtle question. So, I have no idea what to do. 
 A: Edit. I have now a complete answer.
Apologies, but the only way to solve this question I know makes use of factorization of ideals. 
I will use the following well-known facts:
Fact 1. A Dedekind domain is a UFD if and only if it's a PID
Fact 2. A local Dedekind Domain is a PID
Fact 3. The localization of a Dedekind domain is a Dedekind domain.
Fact 4. A noetherian domain is a PID if and only if any maximal ideal is principal.
Since $D\not\equiv 1 [4]$, $R'=\mathbb{Z}[\sqrt{D}]$ is a Dedekind domain. Since $R=\mathbb{Z}_{(p)}[\sqrt{D}]$ is the localisation of $R'$ at $S=\mathbb{Z}\setminus p\mathbb{Z}$, $R$ is also a Dedekind domain (Fact 3).
In particular, $R$ is a UFD if and only if is a PID (Fact 1) . Since $R$ is a noetherian domain, $R$ is a PID if and only if every maximal ideal of $R$ is principal (Fact 4).
Since $R$ is a Dedekind domain (and not a field), maximal ideals are exactly nonzero prime ideals, which are $\mathfrak{p}_{(p)}$, where $\mathfrak{p}$ is a prime ideal of $R'$ not meeting $S$, that is a prime ideal of $R'$ containing $p$.
If $p$ is totally ramified or inert in $\mathbb{Q})(\sqrt{D})$,there is only one $\mathfrak{p}$ lying above $p.$ Thus $R$ is a local Dedekind domain , hence is a PID (Fact 2).
The case where $p$ splits corresponds to the case where $p\nmid D$ and $D$ is a square mod $p$. So, let $m\in\mathbb{Z}$ such that $D=m^2 [p]$ if $p$ is odd, and let $m=1$ if $p=2$. 
We may write $D-m^2=kp, k\in\mathbb{Z}$.
Claim. One may choose $m$ such that $p\nmid k.$
Proof of the claim.
This it is true if $p=2$, since one may take $m=1$ and $D$ is not congruent to $1$ modulo $4$.
Assume that $p>2$. Pick any $m$ such that $D-m^2=kp$ for some $k\in\mathbb{Z}$.
Assume that $p\mid k$ for this choice of $m$ .Then $D-(m+p)^2=D-m^2-2mp-p^2=(k-2m-p)p$. Now since $p\nmid D$, we have 
$p\nmid m$, and since $p$ is odd, $p\nmid 2m$. All in all, $p\nmid k-2m-p$. Henre, replacing $m$ par $m+p$, one may assume that $k\nmid p$ and we are done.
Let us go back to the split case.
The two prime ideals lying above $p$ are $\mathfrak{p}=(p,m+\sqrt{D})$ and $\mathfrak{p}^*=(p,m-\sqrt{D})$. Since $\mathfrak{p}^*$ is the image of $\mathfrak{p}$ under the nontrivial $\mathbb{Q}$-automorphism of $\mathbb{Q}(\sqrt{D})$, it is enough to show that $\mathfrak{p}_{(p)}$ is principal, using facts 1 and 4.
Now $(m+\sqrt{D})(-m+\sqrt{D})=D-m^2=kp$ for some integer $k$.
Since $p\nmid k$,we get $p=(m+\sqrt{D})\dfrac{-m+\sqrt{D}}{k}\in (m+\sqrt{D})_{(p)}$, and we have $\mathfrak{p}_{(p)}=(m+\sqrt{D})_{(p)}$.
Alternative proof. $R$ is a Dedekind domain, whose maximal ideals corresponds to prime ideals of $R'$ lying above $p$. Since these are in finite number, $R$ is a semi-local Dedekind domain. But a semi-local Dedekind domain is known to be a PID (see If R is a semilocal Dedekind Domain, then R is a PID. for example).
Greg
