function scrollToBottom() {
  var $messages = $('#messages');

  if ($messages.length > 0) {
    $messages.scrollTop($messages[0].scrollHeight);
  }
}

$(document).ready(scrollToBottom);

function scrollToBottom() {
  var $messages = $('#messages');

  if ($messages.length > 0) {
    $messages.scrollTop($messages[0].scrollHeight);
  }
}

$(document).ready(scrollToBottom);
$(document).on('turbolinks:load', scrollToBottom);

Fix scrollToBottom action on turbolinks:load
Fix scrollToBottom action on turbolinks:load

