Figured it out :) after much head scratching. I could only seem to return the login page as html rather than redirecting. My solution:
in my authentication check:
unless is_authorized
respond_to do |format|
format.html { redirect_to '/gate' }
format.js { render :json => { redirect: true } , :status => :unauthorized }
end
end # is_authorized
and some javascript:
$.ajaxSetup({
statusCode: {
401: function(data) {
var response = JSON.parse(data.responseText);
if (response.redirect == true) {
location.href = "/gate";
}
}
}
});
So all I really needed to do was send a 401 back when the session is expired, listen for 401s in AJAX calls, and finally redirect if we recieve a 401 and redirect parameter.