Skip to content

Instantly share code, notes, and snippets.

@vdel26
Last active August 29, 2015 14:11
Show Gist options
  • Select an option

  • Save vdel26/9842ab601716f720a9e1 to your computer and use it in GitHub Desktop.

Select an option

Save vdel26/9842ab601716f720a9e1 to your computer and use it in GitHub Desktop.
Update button workaround
<section>
<!-- BUTTON -->
<!-- add this where you would put the tag {{ 'Regenerate' | update_button: application.update_user_key_url }} -->
<form action="{{ application.update_user_key_url }}" class="button_to js-regenerateButton" method="post">
<div>
<input name="_method" type="hidden" value="put">
<input class="btn btn-danger btn-xs" type="submit" value="Regenerate">
</div>
</form>
<!-- ENDBUTTON -->
</section>
<!-- add this script tag to the bottom of the page -->
<script>
$(function () {
var csrfToken = document.querySelector('meta[name=csrf-token]').content,
formContent = document.querySelector('.js-regenerateButton > div'),
inputCsrf = document.createElement('input');
inputCsrf.type = 'hidden';
inputCsrf.name = 'authenticity_token';
inputCsrf.value = csrfToken;
formContent.appendChild(inputCsrf);
});
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment