Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

saveSortOrder doesn't include csrf token #5

Closed
1 task
pascallaliberte opened this issue Jun 13, 2022 · 1 comment
Closed
1 task

saveSortOrder doesn't include csrf token #5

pascallaliberte opened this issue Jun 13, 2022 · 1 comment
Assignees

Comments

@pascallaliberte
Copy link
Member

Steps to reproduce:

Step 1: Prepare a demo project

1.1 Start a new project from the starter repo
1.2 run bin/configure and name application to "Sortable Demo"
1.3. run bin/setup

Step 2: Add a sortable super scaffolded resource

2.1 Create a model: rails g model Book name:string team:references sort_order:integer
2.2 Make sure Team has_many :books
2.3 Super Scaffold a Books Resource with --sortable flag: bin/super-scaffold crud Book Team name:string --sortable

Step 3: Add books, re-order, check console, refresh the page

3.1 Run bin/dev, create an account and from the dashboard, add books
3.2 When a few books are added, attempt a re-order by dragging books into a different order
3.3 Check the console, you should see an 422 error logged into the console
3.4 Refresh the page. The order of books should not be the same as before the refresh

To fix:

  • Make sure that the $.post() request includes the csrf-token meta tag content. This should be in by default across the whole project, but for some reason @rails/ujs doesn't pick up jQuery's inclusion into the project.
@andrewculver
Copy link
Contributor

@pascallaliberte Thank you so much for this! Had someone else also report this today. Glad to be able to give them this fix.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants