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
{{ message }}
This repository has been archived by the owner on Nov 23, 2021. It is now read-only.
I'm wondering if is possible to populate the information without specifying one by one all the column names for example let's say I have a current CSV file with all the valid column names in place but some of the columns need special logic but for all the remaining columns names that appear in the CSV are exactly the same in the model but after to run the importer is only creating the models with the columns that I have specified in other words this is my data:
body; title; votes_count; image_url
some 1, title, 25, , http://example.com/image.jpg
some 2, title, 25, , http://example.com/image.jpg
some 3, title, 25, , http://example.com/image.jpg
# my model
Book(id: integer, title: string, votes_count: integer, body: text, image_file_name: string, image_content_type: string, image_file_size: integer, image_updated_at: datetime)
# My importer
class BookImporter < ActiveImporter::Base
imports Book
column 'image_url', :image do |image_url|
URI.parse(image_url)
end
end
After to run my importer the title, body, and votes_count are nil and only the image is populated correctly.
Any ideas about this behavior?, thanks in advanced guys, btw active importer it is a really good gem :)
The text was updated successfully, but these errors were encountered:
I just made a fork with a small change where this is possible, it tries to match header names with model columns skipping the ones already defined.
Maybe this behavior should be optional. grillermo@7070c02
@grillermo you idea sounds good. I found a problem however, and I left a comment explaining it in the commit that holds your proposed changes.
I also mentioned there, and I think it should be mentioned here as well, that this feature should be enabled explicitly in the importer class, and not assumed that always all importers should use all the model's column names as importer columns. Perhaps something like this:
I'll try to find some time to work on this, or if you want to pitch in with a pull request, go for it. However we need to address the problem I mentioned in the commit's comments before releasing any of this.
Thanks for your interest and your support.
Sign up for freeto subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Hello Guys,
I'm wondering if is possible to populate the information without specifying one by one all the column names for example let's say I have a current CSV file with all the valid column names in place but some of the columns need special logic but for all the remaining columns names that appear in the CSV are exactly the same in the model but after to run the importer is only creating the models with the columns that I have specified in other words this is my data:
After to run my importer the title, body, and votes_count are nil and only the image is populated correctly.
Any ideas about this behavior?, thanks in advanced guys, btw active importer it is a really good gem :)
The text was updated successfully, but these errors were encountered: