Let $R$ be a local ring, and $X$ be any scheme. Prove that every morphism from Spec $R$ to $X$ factors through Spec $\mathcal{O}_{X,x}$.
I know the proof of the similar question when $R$ is a field (see here) and I try to do the same thing. But in this case I can only get a ring morphism from $\mathcal{O}_{X,x}$ to $R/p$= $\mathcal{O}_{SpecR,p}$, where p is a prime ideal. How to get the map from $\mathcal{O}_{X,x}$ to $R$?
The first (and key) step is to show that the image lies in an affine open subscheme of $X$. This follows from the following easy-to-prove facts:
Now simply take $x$ in (2) to be the image of the closed point of Spec $R$. Then, you find that $\text{Spec}(R)\rightarrow X$ factors as: $$\text{Spec}(R)\rightarrow U = \text{Spec A}\subset X$$ the first map is determined by a map of rings $A\rightarrow R$, where the preimage of the maximal ideal $m\subset R$ is some prime ideal $p\subset A$. Since $A\rightarrow R$ sends all elements outside of $p$ to units in $R$, by the universal property of localization, $A\rightarrow R$ factors as $$A\rightarrow A_p\rightarrow R$$ Since $A_p = \mathcal{O}_{X,x}$, we're done.