Let's take the case $N=2$. Suppose we have functions $f(x,y)$ and $r\left(t\right)=\left(r_{1}\left(t\right),r_{2}\left(t\right)\right)$. Then $g(t)=f(r_1(t),r_2(t))$, and the chain rule gives us: $g'\left(t\right)=\frac{\mathrm{d}}{\mathrm{d}t}f\left(r_{1}\left(t\right),r_{2}\left(t\right)\right)$ $=\left(\frac{\partial f}{\partial x}\left(r_{1}\left(t\right),r_{2}\left(t\right)\right)\right)*r_{1}'\left(t\right)+\left(\frac{\partial f}{\partial y}\left(r_{1}\left(t\right),r_{2}\left(t\right)\right)\right)*r_{2}'\left(t\right)$ $=\left(\nabla f\right)\left(r\left(t\right)\right)\bullet r'\left(t\right)$, where $\bullet$ is the dot product.
I think this is what was meant by the formula your teacher gave you, and I am not sure where $n$ is coming in.