TITLE: Restriction of scalars is a right adjoint to tensor product
QUESTION [9 upvotes]: This is the first time I'm asking a question, hope it's not a silly question.
I'm studying through Ravi Vakil's notes, and I came up to this 1.5E exercise that reads like this:
Suppose $A \to B$ is a morphism of rings. If $M$ is a $B$-module,
you can create an $A$-module $M_A$ by considering it as an $A$-module. This gives a functor $\newcommand\Mod{\mathop{\textrm{Mod}}\nolimits}(\,\cdot_A) : \Mod(B) \to \Mod(A)$. Show that this functor is right-adjoint to  $( \cdot \otimes_A B)$. In
other words, describe a bijection
$\newcommand\Hom{\mathop{\textrm{Hom}}\nolimits} \Hom_B(N \otimes_A B,M) \cong
\Hom_A(N,M_A)$ functorial in both arguments.
I can clearly see why $N \otimes_A B$ is a $B$-module (it's enough to define multiplication  $b(n\otimes c)=(n \otimes_b c))$.  I've thought about it but I just can't find a bijection.
Thanks to all in advance.

REPLY [7 votes]: If $M_B$ is a $B$-module, then $M_A\cong\operatorname{Hom}_B(B,M)$, where $B$ is considered as an $A$-$B$-bimodule, so this is the standard adjunction between tensor and Hom.
A direct way of seeing the bijection is to consider $f\colon N\otimes_AB\to M$ and sending it to $\tilde{f}\colon N\to M$ defined by
$$
\tilde{f}(n)=f(n\otimes 1)
$$
which is a morphism of $A$-modules:
$$
\tilde{f}(na)=f(na\otimes 1)=f(n\otimes a)=f((n\otimes 1)a)=\tilde{f}(n)a
$$
Similarly, one can define, given $g\colon N_A\to M_A$,
$$
\hat{g}\colon N\times B\to M
$$
by
$$
g'(n,b)=g(n)b
$$
which is $A$-balanced:
$$
g'(na,b)=g(na)b=g(n)ab=g'(n,ab)
$$
and so $g'$ defines a unique morphism $\hat{g}\colon N\otimes_A B\to M$ (of $B$-modules).
It's a simple verification that we get two maps inverse of each other.