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

MongoDB Support #390

Open kcore opened 3 years ago

kcore commented 3 years ago

Hi @n-rodriguez I am willing to build the Mongoid support for ajax-datatables-rails. I followed https://github.com/jbox-web/ajax-datatables-rails/issues/110 but seems like there have been drastic changes since 0.4.0 to the core library. Do you have some best practices / get started doc on adding more ORM's? Would appreciate if you can point me in the right direction so that I can get this started?

n-rodriguez commented 3 years ago

Do you have some best practices / get started doc on adding more ORM's? Would appreciate if you can point me in the right direction so that I can get this started?

It's very "simple" : create a module named Mongoid in lib/ajax-datatables-rails/orm which responds to these methods :

See: https://github.com/jbox-web/ajax-datatables-rails/blob/master/lib/ajax-datatables-rails/orm/active_record.rb

kcore commented 3 years ago

Thanks. Let me check this and get back!

kcore commented 3 years ago

Hi @n-rodriguez, Sorry for the delay on this. I had already tried doing this before reaching to your and it doesn't work - It throws an error uninitialized constant AjaxDatatablesRails::Mongoid

I see a file https://github.com/jbox-web/ajax-datatables-rails/blob/master/lib/ajax-datatables-rails/active_record.rb - should I be adding a corresponding file for mongoid as well?

Also, I see the following line in base.rb - class_attribute :db_adapter, default: ::ActiveRecord::Base.connection.adapter_name.downcase.to_sym I believe I will have to do something to assign a corresponding mongo adapter...?

kcore commented 3 years ago

Hi @n-rodriguez apologies for following up so frequently and I totally understand you must be caught up with your work & appreciate your responses. I really want to make this happen. is there anyone else that can guide me in the right direction?