Skip to content

Instantly share code, notes, and snippets.

@szTheory
Created October 15, 2019 18:58
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 szTheory/0dcbae2af1d34c224fd4d13e545b509a to your computer and use it in GitHub Desktop.
Save szTheory/0dcbae2af1d34c224fd4d13e545b509a to your computer and use it in GitHub Desktop.
Rails UJS parameters as string. For submitting POST or PUT forms with ajax for Turbolinks
Rails.ajax({
type: 'GET',
url: '/users/' + <%= params[:id] %> + '/country',
// see: https://developer.mozilla.org/en-US/docs/Web/API/URLSearchParams
data: new URLSearchParams({'country': country}).toString(),
success: function (response) {
// ...
}
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment