-
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
before_save, before_create, before_update #442
Comments
What you have stated is completely correct. Because activerecord-import has made use of built in validations to validate records, it got the before/after validation callbacks for free. It's a little more complex now the way validations are implemented, but we tried not to change existing behavior. You're correct too that the recommendation for
I suppose we could consider a PR to add running those callbacks as an option if there is a compelling need. |
@jkowens I see you flagged this as docs, where would be the right place to update to see this documented in the project? |
@oniofchaos I would love to see the Readme get a full revamp and all of these issues I've flagged as docs I think would be good to include. |
Closes zdennis#442 Reorganize the README to explicitly have a section dedicated to usage of activerecord-import, similar to how the wiki is currently laid out. Add a note that the wiki is not to be added to going forward. Migrate the callbacks wiki article to the README, plus add the example from zdennis#442 to add an example of how callbacks and validations can interact in a different fashion.
Start the README refactor and add a section for callbacks Closes #442 Reorganize the README to explicitly have a section dedicated to usage of activerecord-import, similar to how the wiki is currently laid out. Add a note that the wiki is not to be added to going forward. Migrate the callbacks wiki article to the README, plus add the example from #442 to add an example of how callbacks and validations can interact in a different fashion.
My reading of the code is that importing with validation will run the
before_validation
andvalidate
callbacks, but not thebefore_save
andbefore_create
(orbefore_update
) callbacks before saving.On the other hand, the approach in https://github.com/zdennis/activerecord-import/wiki/Callbacks will run the
before_save
andbefore_create
callbacks before the validations, which isn't as expected either (http://api.rubyonrails.org/classes/ActiveRecord/Callbacks.html)Is there a reason why this is so, or am I misreading the code?
The text was updated successfully, but these errors were encountered: