You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
If you check the debugger, you can see that it performs 'Class Create Many Without Validations Or Callbacks', so to do some checks or whatever, you must implement your own callbacks / handling. If I am not mistaken.
You can try wrap 'import' statement inside transaction, I think this will give you more flexibility on error handling.
The #import method returns an object that includes an array of objects that failed validation, so that can be checked to see if any were unsuccessful:
result = Post.import posts
if result.failed_instances.any?
# ...
end
As of version 0.13.0 there is also an #import! method which will raise an exception if a validation error occurs. This means that nothing will be inserted if any objects fail validation.
Hi,
I noticed this issue with gem 'activerecord-import', '0.3.1'
While running tests over my API seems like the inserts fail silently when I have validations w.r.t. some fields presence.
validates_presence_of :attr1, :attr2
Doesn't the gem throw an error if the above validation fails? ActiveRecord does throw an error in such cases.
The text was updated successfully, but these errors were encountered: