Всем спасибо! Вот решение вопроса:
var new_timer;
$(document).on('ready page:load', function () {
    if (typeof new_timer != 'undefined') {
        clearInterval(new_timer);
        add_timer();
    }
    else {
        add_timer();
    }
});
$(document).on('page:fetch', function () {
    clearInterval(new_timer)
});
function add_timer() {
    new_timer = setInterval(function(){
    $.ajax({
        type: "POST",
        url: "/sidebar",
        data: "user=" + <%= current_user.id %> + "&cpe=" + <%= @cpe_instance.id %>,
        success: function(msg){
            if (msg.error == "no") {
            console.log("Some message");
            }
            else {
                console.log(msg.error);
            }
        }
    });
    }, 500);
}