-
Notifications
You must be signed in to change notification settings - Fork 63
Rails 5: undefined method `fuzzily_searchable' #53
Comments
I've run into the same issue on a rails 4.2 project. All the fuzzily methods work correctly on the console and in my tests, but l get an undefined method error when they are called from the AR model. |
The issue is in /lib/fuzzily/searchable.rb, it has a case that includes the fuzzily_searchable methods, adding a 'when 5' fixes this problem: def self.included(by)
case ActiveRecord::VERSION::MAJOR
when 2 then by.extend Rails2ClassMethods
when 3 then by.extend Rails3ClassMethods
when 4 then by.extend Rails4ClassMethods
when 5 then by.extend Rails4ClassMethods
end
end |
panna theriyalappa puriyira mathiru poduppa ... |
@samuelgiles do you have a fix PR? |
Also having this issue, any progress on a solution? |
There are at least two PRs for this, but the repo hasn't received a commit in over a year (Aug 2015), so it seems dead (or just sleeping?). At any rate, a workaround for this issue in Rails 5 applications is extending ActiveRecord::Base with the appropriate methods:
|
I'm pretty sure it's dead. Also, the current version does not work on 5.2 because of changes in callbacks between 5.0 and 5.2 (trigrams are no longer updated on name changes or creating new records). I've been using a fork from cardillomarcelo up to now but it's disappeared (he probably gave up on this gem), but since I still need it, I created a fork that fixes this. It's provided only on a "works for me" basis (but feel free to send in PR's). |
Oh no, I guess I have to fork. I'm upgrade to rails 5, one of my applications. Is there a lead fork, that is maintained now? |
Trying to see if I can wire this up to a rails 5 api-only application, I've got the trigram model and migration set up correctly, but in my AR model when I include
fuzzily_searchable :name
(yes its actually called :name in my model) I get the undefined methodfuzzily_searchable
error.The text was updated successfully, but these errors were encountered: