Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 777027
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T19:32:30+00:00 2026-05-14T19:32:30+00:00

I need to populate my production database app with data in particular tables. This

  • 0

I need to populate my production database app with data in particular tables. This is before anyone ever even touches the application. This data would also be required in development mode as it’s required for testing against. Fixtures are normally the way to go for testing data, but what’s the “best practice” for Ruby on Rails to ship this data to the live database also upon db creation?

ultimately this is a two part question I suppose.

1) What’s the best way to load test data into my database for development, this will be roughly 1,000 items. Is it through a migration or through fixtures? The reason this is a different answer than the question below is that in development, there’s certain fields in the tables that I’d like to make random. In production, these fields would all start with the same value of 0.

2) What’s the best way to bootstrap a production db with live data I need in it, is this also through a migration or fixture?

I think the answer is to seed as described here: http://lptf.blogspot.com/2009/09/seed-data-in-rails-234.html but I need a way to seed for development and seed for production. Also, why bother using Fixtures if seeding is available? When does one seed and when does one use fixtures?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-14T19:32:30+00:00Added an answer on May 14, 2026 at 7:32 pm

    Usually fixtures are used to provide your tests with data, not to populate data into your database. You can – and some people have, like the links you point to – use fixtures for this purpose.

    Fixtures are OK, but using Ruby gives us some advantages: for example, being able to read from a CSV file and populate records based on that data set. Or reading from a YAML fixture file if you really want to: since your starting with a programming language your options are wide open from there.

    My current team tried to use db/seed.rb, and checking RAILS_ENV to load only certain data in certain places.

    The annoying thing about db:seed is that it’s meant to be a one shot thing: so if you have additional items to add in the middle of development – or when your app has hit production – … well, you need to take that into consideration (ActiveRecord’s find_or_create_by…() method might be your friend here).

    We tried the Bootstrapper plugin, which puts a nice DSL over the RAILS_ENV checking, and lets your run only the environment you want. It’s pretty nice.

    Our needs actually went beyond that – we found we needed database style migrations for our seed data. Right now we are putting normal Ruby scripts into a folder (db/bootstrapdata/) and running these scripts with Arild Shirazi’s required gem to load (and thus run) the scripts in this directory.

    Now this only gives you part of the database style migrations. It’s not hard to go from this to creating something where these data migrations can only be run once (like database migrations).

    Your needs might stop at bootstrapper: we have pretty unique needs (developing the system when we only know half the spec, larg-ish Rails team, big data migration from the previous generation of software. Your needs might be simpler).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I need to populate a context menu from a database at run time. I
I have an application where I need to populate a textbox with a company
I have a need to populate a Word 2007 document from code, including repeating
I have a structure which I need to populate and write to disk (several
I am using ASP.NET 2.0 and VS 2005. I need to populate a grid
If I have a business object with 50 fields, and I need to populate
Need a function that takes a character as a parameter and returns true if
Need a way to allow sorting except for last item with in a list.
Need to an expression that returns only things with an I followed by either
Need to locate the following pattern: The letter I followed by a space then

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.