Skip to content

Commit

Permalink
Fix for #2873 - CSRF Exception after adding to Collections/Sharing
Browse files Browse the repository at this point in the history
- Found the root issue is related to turbolinks + jquery-ujs + a button that uses ajax to post. This may also fix #1191. Adding a call to refresh the CSRF tokens in the rendered DOM after turbolinks loads fixes it.
  • Loading branch information
jgondron committed Mar 29, 2018
1 parent f881381 commit 4ed084e
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
1 change: 1 addition & 0 deletions app/assets/javascripts/hyrax.js
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@
//= require hyrax/thumbnail_select
//= require hyrax/batch_select
//= require hyrax/tabbed_form
//= require hyrax/turbolinks_events

// this needs to be after batch_select so that the form ids get setup correctly
//= require hyrax/batch_edit
5 changes: 5 additions & 0 deletions app/assets/javascripts/hyrax/turbolinks_events.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
// Fixes a problem with csrf tokens and turbolinks
// See https://github.com/rails/jquery-ujs/issues/456
$(document).on('turbolinks:load', function() {
$.rails.refreshCSRFTokens();
});

0 comments on commit 4ed084e

Please sign in to comment.