
Building a Rails Engine #14 -- Dry Run: Validate Before You Import
Dry Run: Validate Before You Import The preview catches column errors. The dry run catches database errors. Two safety nets, two levels of confidence. Context This is part 14 of the series where we build DataPorter , a mountable Rails engine for data import workflows. In part 13 , we detailed the testing strategy: in-memory SQLite, structural controller specs, anonymous target classes, and a spec_helper that bootstraps just enough Rails to cover every layer. We now have a complete import pipeline: parse the file, preview the records, confirm, persist. But there is a gap between the preview and the real import. The preview validates the data -- required fields, types, formats. It does not validate what happens when that data hits the database. A uniqueness constraint, a foreign key violation, a custom model validation that queries other tables -- none of these surface until persist is actually called. By then, the import is running for real. In this article, we build a dry run mode that
Continue reading on Dev.to Tutorial
Opens in a new tab




