Comments (5)
Hey @stevenou , I'm glad that this gem is saving you some time!
Thank you for reporting this. I believe that it's coming from:
csv-importer/lib/csv_importer/row.rb
Line 80 in 26d66cb
I'm wondering if this API (errors.each do |error|
) is compatible with Rails 4+ or if there's something like errors.to_h
.
PRs are welcomed. ;)
from csv-importer.
Ok, so it would appear that csv-importer
currently actually only returns the last error for each attribute, not all errors for each attribute. That's because the Hash[]
here will only retain the last error if there are multiple entries with the same key (column_name
/attribute
)
csv-importer/lib/csv_importer/row.rb
Lines 79 to 87 in 26d66cb
Ideally, we might want to change the value in the resulting hash to be an array, rather a string, so it can hold all errors for a given attribute. However, that is probably a breaking change.
So I'll just submit a PR to remove the deprecation warning but keep the existing behavior. We can discuss the breaking change separately.
from csv-importer.
You're 100% right. I'm not convinced that only keeping the last error was intentional. Let's merge your PR in for the 0.8.1
version. I believe that we could then release 0.9.0
where errors
would return a hash where values would be array of errors.
from csv-importer.
May I suggest making that 1.0.0 as that would be a breaking change?
from csv-importer.
@stevenou Yes, that makes sense. It always feels like a big jump to release 1.0.0 but it's the right call. I'm going to look at removing the dependency to virtus
since it's not maintained anymore.
from csv-importer.
Related Issues (20)
- How to find_by another model's attribute? HOT 1
- Allow manual mapping HOT 2
- Adding an error to a row from a to: block? HOT 3
- Cannot access instance variable in after_build HOT 1
- skip! does not indicate which row was skipped in the report HOT 1
- Many to many association HOT 1
- Possible to bypass existing callbacks HOT 2
- Encodings HOT 1
- Encoding - German Umlaute ignored. HOT 1
- Upload file HOT 5
- Add i18n to messages HOT 2
- Exception when model.save fails HOT 2
- Memory bloat when processing large files HOT 2
- Make transactions optional HOT 4
- A normalization feature? HOT 4
- German umlauts issue HOT 3
- Ruby 2.7.1 - ArgumentError: unknown encoding name - UTF-8:UTF-8 HOT 2
- Question: Pass a parameter to an import? HOT 6
- Question: Is there a way to programmatically get the column mapping to see which columns of the CSV file are being mapped to which columns/attributes of the model?
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from csv-importer.