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
587 stars 228 forks source link

undefined method `searchable?' for nil:NilClass #343

Closed jasper502 closed 4 years ago

jasper502 commented 5 years ago

I brought to life a dormant Rails app that had the old version of this gem. I have followed all the upgrade instructions and even created a new datatable controller via the generator. My JSON fails each time with:

undefined methodsearchable?' for nil:NilClass ` which I traced back to:

build_conditionsajax-datatables-rails (1.0.0) lib/ajax-datatables-rails/orm/active_record.rb

      def build_conditions
        if datatable.searchable?
          build_conditions_for_datatable
        else
          build_conditions_for_selected_columns
        end
      end

Can't seem to find this error anywere else. I can post my code if needed but I literally have followed the basic example in the readme.

n-rodriguez commented 4 years ago

Hi there! Any news?

aximuseng commented 4 years ago

I gave up trying and stuck with v0.4. I plan to try and upgrade again over the Christmas break.

n-rodriguez commented 4 years ago

Ok Keep me updated!

blrobin2 commented 4 years ago

@jasper502 I encountered this issue when I did not pass in the params object to the Datatable constructor in the controller. In addition, I was overriding the initialize method without calling super. Once I did those things, the error went away. I'm not saying you are doing exactly those things, but those might be places to check... hope that helps!

aximuseng commented 4 years ago

I think I fixed it but now have other unrelated issues (will post new issue on that). Followed the examples line for line and it seems to work now.