Consider looking into $.ajaxDefaults to make this beforeSend happen automatically on all AJAX requests. (I think it actually does if you use jquery-rails?)