how to return to last viewed page?

I have a Contact Us link in the footer of most of my pages. Clicking
this takes the user to a new page containing a form for sending us a
msg of some sort.

The form has Submit and Cancel buttons.

After the user clicks one of these buttons to post the message, I'd
like to return them to whatever page they were viewing before they
clicked Contact Us.

Anyway to do this?

Thanks, Shai.

I like the second option since it seems more robust... but I'm missing
what you mean by "store the id of the page"... what id would serve as
the identifier in this case?

BTW -

I tried using

redirect :back

which seems obvious and I think is quite similar to what Shai is
suggesting, but all it does is return to the Contact Us form page

any thoughts?

I usually do this by appending a :return_to => request.request_uri at
the end of the link_to that links to the contact form. Then add a
before filter that stuffs that parameter into the session, and use
that session variable for the destination for the redirect after the
form has been submitted. If you are using acts_as_authenticated, you
already have the redirect_back_or_default method that makes this
easy. The cancel button can also take a peek at this session
variable to know what its destination should be.