I am using [devise](http://blog.plataformatec.com.br/tag/devise/). I want to redirect to previous page after sign in process is successful. The problem I am having is that the request.referer always has sign\_in URL in it. How can I get the URL of the previous page without some explicit hooks.

```
def after_sign_in_path_for(resource)
   stored_location_for(resource) || request.referer || search_index_path
end

```