Skip to content
This repository was archived by the owner on Nov 23, 2021. It is now read-only.
This repository was archived by the owner on Nov 23, 2021. It is now read-only.

Populate information without to specify all the column names #28

@heridev

Description

@heridev

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:

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 :)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions