mezis/fuzzily

Doesn't work with single table inheritance

Closed this issue · 4 comments

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'.

I suppose the solution is to move the fuzzily_searchable from the superclass into the subclasses.

@airblade, that sounds like a plan. Tell me if that works? And if it doesn't I'll take a PR or suggestions ;)

Moving fuzzily_searchable down into the subclasses works fine.

I fixed the code to work with single table inheritance.
airblade@02562e6