Skip to content

Instantly share code, notes, and snippets.

@nikolalsvk
Last active May 11, 2019 02:57
Show Gist options
  • Save nikolalsvk/f0f3d8141bf402b2b13ec58bc31e0ddc to your computer and use it in GitHub Desktop.
Save nikolalsvk/f0f3d8141bf402b2b13ec58bc31e0ddc to your computer and use it in GitHub Desktop.
<!-- app/views/movies/show.html.erb -->
<div id="rating">Loading rating...</div>
<script>
const checkRating = () => {
fetch("<%= movie_rating_path(@movie) %>")
.then(response => response.text())
.then(response => {
document.getElementById("rating").innerHTML = response;
});
};
setInterval(checkRating, 2000);
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment