
Building a Rails Engine #6 — Parsing CSV Data with Sources
Parsing CSV Data with Sources How to model an import record in the database, parse CSV files through a pluggable Source layer, and map headers to target columns -- the first end-to-end flow. Context This is part 6 of the series where we build DataPorter , a mountable Rails engine for data import workflows. In part 5 , we designed the Target DSL and Registry -- the layer that describes what an import looks like: its columns, mappings, and persistence logic. Now we need the other half: the code that represents an import in progress and the code that reads raw data from a file. By the end of this article, we will have a DataImport ActiveRecord model to track state, a Source abstraction for parsing, and a concrete CSV source that maps headers to target columns. This is where data first flows through the engine. The problem Without a Source layer, every import reinvents CSV parsing. Different controllers. Different header-matching logic. Different error handling. Different bugs. # Controlle
Continue reading on Dev.to Tutorial
Opens in a new tab


