jbox-web / ajax-datatables-rails

A wrapper around DataTable's ajax methods that allow synchronization with server-side pagination in a Rails app
MIT License
585 stars 228 forks source link

ActionDispatch::Http::Parameters::ParseError #354

Closed PavloBezpalov closed 4 years ago

PavloBezpalov commented 4 years ago

Hi. When i try to use POST like described in readme

$ ->
  $('#posts-datatable').dataTable
    ajax:
      url: $('#posts-datatable').data('source')
      contentType: 'application/json'
      type: 'POST'
    # ...others options, see [here](#5-wire-up-the-javascript)

i got error in Rails ActionDispatch::Http::Parameters::ParseError

So i tried to format params in json like this

$ ->
  $('#posts-datatable').dataTable
    ajax:
      url: $('#posts-datatable').data('source')
      contentType: 'application/json'
      type: 'POST'
      data: (d) ->
        JSON.stringify d

But I got NoMethodError: undefined method to_unsafe_h' for #<Array at ajax-datatables-rails-1.1.0/lib/ajax-datatables-rails/datatable/datatable.rb:73:inget_param'

PavloBezpalov commented 4 years ago

Found solution. I should not use contentType: 'application/json' in first example :(