Skip to content

Instantly share code, notes, and snippets.

@haggen
Created August 21, 2014 23:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save haggen/c8dd092f19e5d6a58553 to your computer and use it in GitHub Desktop.
Save haggen/c8dd092f19e5d6a58553 to your computer and use it in GitHub Desktop.
Auto refresh CSS on Rails+turbolinks
...
<%= javascript_tag do %>
// Auto refresh CSS every 2s, only on development, turbolinks ready
!this.REFRESHER && (this.REFRESHER = setInterval(function() {
$('link[rel="stylesheet"]').attr('href', function(index, value) {
return value.replace(/\?.+|$/, '?' + Math.random());
});
}, 2000));
<% end if Rails.env.development? %>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment