-
Notifications
You must be signed in to change notification settings - Fork 617
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
How to require activerecord-import? #474
Comments
Ok so I have to load activerecord-import before active_record is loaded: https://github.com/zdennis/activerecord-import/blob/master/lib/activerecord-import.rb#L3 I'm wondering if that should be added to the readme? There is discussion of how adapters need to be loaded, but not activerecord-import itself. |
I wonder if a lot of people require activerecord-import after active record and then just assume it made no difference to their imports or that it's broken. Perhaps there should be some warning when activerecord_import thinks that the connection doesn't "support_import". |
@gerrywastaken I'd have to do some reading on ActiveSupport's lazy loading to better understand what is going on. @amatsuda are you able to provide any insight and/or suggestions? |
@gerrywastaken in your script if you just do:
Does that work? |
There is a wiki entry on how to require activerecord-import. I just want to make sure that it is accurate. Hopefully this will end up in the readme one of these days 😜 https://github.com/zdennis/activerecord-import/wiki/Requiring |
Nope, because the onload of active_record would have already been triggered and so this is this never run: |
it would be better if there was just a call we could make to initialize activerecord-import at any time no matter the load order. |
So I did some testing and the following at the beginning of your script should do the trick:
I updated the wiki, but I'll see about adding a method to simplify that initialization. |
That's pretty helpful, thanks @jkowens! |
When I set
require: false
in my Gemfile and instead do the following in a scriptactiverecord-import instead tries to do every insert as a single insert. What am I doing wrong here?
I can see that supports_import? is somehow being set to false and this is why it doesn't work, but I'm not sure why that would be the case.
The text was updated successfully, but these errors were encountered: