How to find a bijection between R-valued points of X and local ring homomorphisms?

I am trying to prove the following fact for a homework assignment in algebraic geometry:

Let R be a local ring, and X a prescheme. Show that there is a one-one correspondence between R-valued points on X and pairs (x, g) of points x on X and local homomorphisms $g: O_{X, x} \to R$.

Now, given f: Spec R -> X, and writing x for f(M) where M is the maximal ideal of R, the induced map on stalks gives us a map $g: O_{X,x} \to R_M = R$. Then it remains to show that given a point x of X and a map $g: O_{X,x} \to R$, that there is a map f: Spec R -> X such that f(M) = x and such that the induced map is g.

I haven't had any luck yet with associating a map f with a given g. Here are my thoughts and some of the things I've tried:

1. When R is a field, then Spec R has only a single point, and thus the map f is completely determined by where it sends the zero ideal. This induces a local homomorphism from $O_{X,x}$ to k, which is to say that it induces a map from $O_{X,x} / M_x \to k$ since the maximal ideal $M_x$ of $O_{X,x}$ is contained in the kernel of the local homomorphism. Anyway, as long as there is some local homomorphism from $O_{X,x}$ to k, then the map f sending (0) to x is a well-defined morphism. Now, when R is again just a local ring, it seems unlikely that f is completely determined by where it sends M, and I can't see how to work with this.

2. I've tried extending the map g to a map of sheaves, thinking that maybe from there I'd be able to find my map of preschemes. But here I get a little lost, and I'm not sure how to make it work.

3. We know a lot about the topology of Spec R, and this forces some properties of X. For example, the only open neighborhood of M in Spec R is the whole space. Therefore, f(Spec R) covers any open neighborhood of f(M). I haven't pursued this way very far yet, as it seems a little further afield.

I just need a little hint to get me going again -- I've been thinking about this one for a while and I can't seem to get unstuck.

• I've given a hint in an answer, but there's a general principle at work here. When you're defining a morphism of (pre)schemes, you usually want to do it by defining morphisms on open affines, which reduces to defining ring morphisms in the opposite direction. It's tempting to try to start off by constructing a map of topological spaces, then a morphism of the appropriate sheaves, but this tends to be intimidating and confusing. – Charles Staats Nov 9 '10 at 3:16
• Just to second Charles's comment: you may want to imagine first that $X =$ Spec $A$ for some ring $A$, translate everything into ring theoretic terms, and see if you can then solve the problem. Then go back to the scheme-theoretic setting. (As Charles's remarks above and answer below suggest, the problem in fact reduces to the case when $X$ is affine.) – Matt E Nov 9 '10 at 3:50
• I hadn't realized how useful #3 would be. If U is an open affine neighborhood of f(M), then its preimage is an open neighborhood of M, which must then be Spec R. So Spec R maps into an affine neighborhood U = Spec A, and the problem reduces to the case where X = Spec A, which is not too hard. Thank you both for your help! – Gabe Cunningham Nov 9 '10 at 16:59

For any point $x \in X$, there is a canonical morphism $\mathrm{Spec} \mathcal{O}_{X, x} \to X$. To prove this, first take an affine neighborhood of $x$. You may also want to look at the definition of a morphism of locally ringed spaces / schemes, specifically, the requirement on stalks.
Let $s$ be the special point of $Spec(R)$, i.e. the one which corresponds to the unique maximal ideal of $R$. Then every point $p$ of $Spec(R)$ generalizes to $s$, i.e. $s \in \overline{\{p\}}$. If $f : Spec(R) \to X$ is a continuous map, we thus have $f(s) \in \overline{\{f(p)\}}$, i.e. every open neighborbood of $f(s)$ contains $f(p)$. In other words, if $U$ is an open neighborhood of $f(s)$, the map $f$ actually factors as $Spec(R) \to U \to X$. If $f$ is a morphism of schemes, this is also a factorization in the category of schemes.
Thus a morphism $f : Spec(R) \to X$ mapping $s \mapsto x$ corresponds to a equivalence class of morphisms $Spec(R) \to U$ mapping $s \mapsto x$, where $U$ is an affine open neighboord of $x$. Such a morphism corresponds to a homomorphism $\mathcal{O}_X(U) \to R$, and since we consider equivalence classes, we get a homomorphism $\mathcal{O}_{X,x} \to R$, whose locality corresponds to the condition $s \mapsto x$ above.