With devise one uses before_filter :authenticate_user! to restrict access to authenticated users only.
When an unauthenticated
A version mixing event binding with location.reload():
$(function($) {
  $("#new-user")
    .bind("ajax:error", function(event, xhr, status, error) {
      if (xhr.status == 401) {  // probable Devise timeout
        alert(xhr.responseText);
        location.reload();      // reload whole page so Devise will redirect to signin
      }
    });
});
Testing with Devise 3.1.1, this does correctly set session["user_return_to"], so the user returns to the page after signing in again ().
I added the alert as a simple way to address the inelegant message issue discussed here:  Session Timeout Message in RoR using Devise