meilisearch / meilisearch-rails

Meilisearch integration for Ruby on Rails
https://www.meilisearch.com
MIT License
308 stars 47 forks source link

problem support custom primary key #251

Closed masukomi closed 1 year ago

masukomi commented 1 year ago

Description this builds on #250 BUT if we fix that issue ... we run into the next one

this line

        condition_key = meilisearch_options[:type].primary_key if has_virtual_column_as_pk

calls the primary_key method on the model. Mongoid doesn't have a primary_key method and it seem to be doing anything with the fact that I've added the following to my model. It should be calling my ms_id method but it's hardcoded to call primary_key

meilisearch primary_key: :ms_id

this may actually be an issue that extends beyond mongoid, but i can't test that at the moment.

Expected behavior call the primary key method i told it to.

Current behavior it called .primary_key which is a non-existent method.

Task.find('foo')
/Users/masukomi/.rbenv/versions/3.2.0/lib/ruby/gems/3.2.0/gems/meilisearch-rails-0.9.0/lib/meilisearch-rails.rb:650:in `ms_search': undefined method `primary_key' for Task:Class (NoMethodError)

        condition_key = meilisearch_options[:type].primary_key if has_virtual_column_as_pk

Environment (please complete the following information):

brunoocasali commented 1 year ago

Following my comment in the previous issue #250 we need to proper test and fix the issues in the MongoId.

brunoocasali commented 1 year ago

I'm going to close this issue because all the MongoDB requests are going to be tracked in the issue https://github.com/meilisearch/meilisearch-rails/issues/175.