How to redirect back to the page after user Login?

Hello all,

I am using acts_as_authenticated as my login system.

it does a good job redirecting back to where the user were after login, when using the controller action fliter.

however if i use a link in my page to link to the login page, it doesn't redirect back to where the user were after login.

i have a look at the code of AAA, it uses    1. redirect_back_or_default(:controller => '/account', :action => 'index')    2.    3. #code for redirect_back_or_default    4. def redirect_back_or_default(default)    5. session[:return_to] ? redirect_to_url(session[:return_to]) : redirect_to(default)    6. session[:return_to] = nil    7. end to redirect back to the origin page.

how and where to set the session[:return] in my app to make it redirect back to the origin page after login?

Thanks all.