Doesn't work with single table inheritance
Closed this issue · 4 comments
airblade commented
I have classes like this:
class Person < ActiveRecord::Base
fuzzily_searchable :name
end
class Employee < Person; end
class Freelancer < Person; end
The following returns 0 records:
Freelancer.find_by_fuzzy_name 'john'
This is because the polymorphic trigrams.owner_type
is queried as 'Freelancer'
not 'Person'
.
airblade commented
I suppose the solution is to move the fuzzily_searchable
from the superclass into the subclasses.
mezis commented
@airblade, that sounds like a plan. Tell me if that works? And if it doesn't I'll take a PR or suggestions ;)
airblade commented
Moving fuzzily_searchable
down into the subclasses works fine.
airblade commented
I fixed the code to work with single table inheritance.
airblade@02562e6