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

  • SEARCH
  • Home
  • 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 6241983
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T11:52:04+00:00 2026-05-24T11:52:04+00:00

When my current project started I was still learning RoR and we had a

  • 0

When my current project started I was still learning RoR and we had a more experienced guy driving our project organization (where files go, what we do to work with the project). One of the things he asserted is that when you have seed data for tables you put that seed data into the migrations themselves. And he also asserted that db/seeds.rb was only used for setting up the test db between tests when executing units or ATs (we use rspec and cucumber respectively).

Recently I’ve been reading various answers here that imply that we’re doing this incorrectly and I’m hoping that someone here can give me a deeper explanation of what the “Rails Way” is for this.

thanks!

EDIT:

A few things that I need to understand:

a. How DO I ensure that this seeded data is in the database for tests. I’ve been told that rspec tests clean the database by putting the test in a transaction and at the end simply rolling back that transaction so if that is true, does the test database get seeded before the entire run of tests? What causes the seeding to happen.

rake db:test:prepare

doesn’t seem to seed the database, although I might be mistaken

b. do I have to actually run

rake db:migrate
rake db:seed

after a migration is introduced that requires new seed data to be added to db/seeds.rb?

c. do I have to enclose each individual part of the seeding with checks to make sure it’s necessary so that I don’t get exceptions when rerunning a seeds and having, for example, uniqueness constraints violated when re-seeding is attempted on things previously seeded. (which leads to the question, is that question even syntactically correct??).

I think that the thing that led “our guy” down the path of seeding in the migrations is that we can count on the entire migration mechanism not to rerun previous seeds rather than checking everything in seeds.rb before attempting the seed…

I hope this is clearer…

  • 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-24T11:52:05+00:00Added an answer on May 24, 2026 at 11:52 am

    Migrations are for manipulating the structure of your database, not for the data within it and certainly not for simple population tasks.

    simply this is a rake task that sucks in the data specified in a db/seeds.rb.

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

Sidebar

Related Questions

In my current project we are testing our ASP.NET GUI using WatiN and Mbunit
On my current project, I came across our master DB script. Taking a closer
I've started using Mercurial for version-controlling my Drupal project source files (I'm both a
Hello I just started working with CodeIgniter framework. My current directory structure is Demo(Project
I'm relatively new to programming and a recent project I've started to work on
My current project is in Rails. Coming from a Symfony (PHP) and Django (Python)
My current project uses NUnit for unit tests and to drive UATs written with
My current project involves deploying an upgraded .exe file that runs as a Windows
My current project involves writing Perl code inside a Solaris VMWare appliance (hosted on
On my current project, we've been using Struts 1 for the last few years,

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.