TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

Smarter Rails Seeding with Sprig

30 pointsby dceabout 11 years ago

5 comments

rpwilcoxabout 11 years ago
It looks like using Rails test fixtures (reborn) to create seed data. Which is an OK win I guess, and having it separated out by environment (implicitly mentioned in the article) is nice.. but I don&#x27;t see how much of a win this is over instantiating fixtures or FactoryGirl.create in your seeds.rb file.<p>Yes, there are tons of problems with using db&#x2F;seeds.rb for anything serious. I&#x27;m not sure that Sprig will handle my issues much better than I currently do myself.<p>For the record, my desired behaviors for a seed data solution are:<p>1. environmental separation (which Sprig has). Developers have different needs for seed data as QA does, as does the staging server, as does production. Developers want an easy default dev@myco.com user with a simple password, but you don&#x27;t want that in production.<p>2. If I rerun my seed solution (perhaps because I added some more seed data) it shouldn&#x27;t duplicate records (or throw errors because it&#x27;s trying to create the second user with the same email address)<p>3. Handle bootstrap data I need in my app (example: I want a list of US states, and every environment should get this. To reiterate my second point, I should be able to add to this bootstrap data without getting two copies of &quot;California&quot; in my US state list).<p>It&#x27;s sad that no real solution exists to handle all three of these needs. Some projects I&#x27;ve been on have gotten this close, but that was years ago and things have changed.<p>(If Sprig does have these things, then that&#x27;s the selling point, not seed data as fixtures which the article emphasized)<p>I&#x27;m also not sure about using fixture like things in Sprig. I give it 6 months before most users remember why many people in the Rails community moved to a Factory pattern for (test) data construction long ago.<p>However, I am happy that a relatively well known Rails consultancy is released 1.0 of a seed gem. Hopefully the name recognition &#x2F; noise will lead developers to the gem and I&#x27;ll be a better solution with many more eyes.
评论 #7358323 未加载
dansoabout 11 years ago
I completely expected the OP to have had a typo in the headline and for it to actually be about &quot;Spring&quot;, which is an amazing an essential gem (and part of 4.1beta)...but this is pretty cool too :).<p>I&#x27;m biased because the OP shows off a custom-parser for Google Spreadsheets, which is neat to me because Google Spreadsheets is my goto-interface for new prototyped apps...a much better, live-collaborative admin than anything I could easily build myself or with Rails tools.<p>But I wonder if this gem is more work than its worth? I mean, seeds don&#x27;t seem like the best place to persist intricate production-ready data in the repo. And if you continue to use Google Spreadsheets, or whatever, as your main admin input interface, then it seems worth it to build a more elaborate abstraction to handle that usecase.<p>Also, I wonder if some of the self-referencing could be done via YAML&#x27;s standard syntax? That would mean no JSON as a format, but YAML seems like it was built for this kind of lightweight relational data storage?
评论 #7354762 未加载
bigtunacanabout 11 years ago
This feels like just re-inventing the wheel again. The seedbank gem <a href="https://github.com/james2m/seedbank" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;james2m&#x2F;seedbank</a> has been around for a couple of years and does a great job for managing seeds on a natural, more granular level, if that is what you need.
tbruffyabout 11 years ago
Seems like an oversight not to include XML support
hmansabout 11 years ago
No. Just no.