Skip to content

Commit

Permalink
Expose score on matching records.
Browse files Browse the repository at this point in the history
Note this checks that each match has an owner to handle matches whose
owners aren't in the caller's scope.
  • Loading branch information
airblade committed Sep 30, 2013
1 parent b91323e commit 8b41888
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion lib/fuzzily/model.rb
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,11 @@ def _matches_for_trigrams(trigrams)
group('owner_id, owner_type').
order('matches DESC, score ASC').
with_trigram(trigrams).
map(&:owner)
map do |t|
owner = t.owner
owner.instance_eval "def fuzzily_score; #{t.score}; end" if owner
owner
end
end

def _add_fuzzy_scopes
Expand Down

0 comments on commit 8b41888

Please sign in to comment.