Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Model#import method name clashes with activerecord-import library #1011

Open
scarrick68 opened this issue Oct 8, 2021 · 2 comments
Open
Labels

Comments

@scarrick68
Copy link

The import method is shadowed by activerecord-import which results in this argument error:
ArgumentError: Invalid arguments! from /some_local_path/activerecord-import-1.2.0/lib/activerecord-import/import.rb:648:in import_helper'`

Ruby doesn't support method overloading so it doesn't recognize any other definition. I'm guessing only the most recent for that class / module. Just wanted to point this out for anyone who runs into the same issue since AR import gem is pretty popular, 47 MM downloads.

My hot fix was to remove AR import, bundle and run the import. This won't work for anyone who runs a periodic import job.

I'd be happy to alias the method and make a PR.

@Quicks
Copy link

Quicks commented Nov 5, 2021

Hi
I have used elasticsearch proxy __elasticsearch__
and works perfect)

for example:
User.elasticsearch.import

if you need to import specific models you can use query parameter
User.elasticsearch.import query: -> { User.where(id: ids) }

Maybe it will help you

@stale stale bot added the stale label Apr 17, 2022
@picandocodigo picandocodigo added bug and removed stale labels Apr 18, 2022
@elastic elastic deleted a comment from stale bot Apr 18, 2022
@rsmithlal
Copy link

I did a similar proxy by creating an elastic_import method that I call when importing records;

      # Need to create another way to access elasticsearch import.
      # class.import is using by activerecord-import, I think
      def self.elastic_import
        __elasticsearch__.import
      end

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

No branches or pull requests

4 participants