With devise one uses before_filter :authenticate_user! to restrict access to authenticated users only.
before_filter :authenticate_user!
When an unauthenticated
$(document).ajaxError(function (e, xhr, settings) { if (xhr.status == 401) { $('.selector').html(xhr.responseText); } });