ajax-datatables-rails icon indicating copy to clipboard operation
ajax-datatables-rails copied to clipboard

MongoDB Support

Open kcore opened this issue 4 years ago • 4 comments
trafficstars

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?

kcore avatar May 04 '21 11:05 kcore

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 :

  • filter_records
  • sort_records
  • paginate_records

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

n-rodriguez avatar May 05 '21 13:05 n-rodriguez

Thanks. Let me check this and get back!

kcore avatar May 05 '21 14:05 kcore

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 avatar May 06 '21 05:05 kcore

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?

kcore avatar May 10 '21 01:05 kcore