Skip to content
This repository has been archived by the owner on Sep 27, 2022. It is now read-only.

Rails 5: undefined method `fuzzily_searchable' #53

Open
zachdaniel opened this issue Oct 22, 2015 · 8 comments
Open

Rails 5: undefined method `fuzzily_searchable' #53

zachdaniel opened this issue Oct 22, 2015 · 8 comments

Comments

@zachdaniel
Copy link

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 method fuzzily_searchable error.

@dschlitt
Copy link

dschlitt commented Dec 3, 2015

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.

@samuelgiles
Copy link

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

@mohanadevi
Copy link

panna theriyalappa puriyira mathiru poduppa ...

@sunapi386
Copy link

@samuelgiles do you have a fix PR?

@DannySantos
Copy link

Also having this issue, any progress on a solution?

@speckins
Copy link

speckins commented Oct 27, 2016

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:

# config/initializers/fuzzily.rb:
ActiveRecord::Base.extend(Fuzzily::Searchable::Rails4ClassMethods)

@fjl82
Copy link

fjl82 commented Jul 16, 2018

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

@Tectract
Copy link

Tectract commented Jan 7, 2021

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?

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

9 participants