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 9198451
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T22:17:09+00:00 2026-06-17T22:17:09+00:00

I have to prepare a rather large amount of seed data for a Rails

  • 0

I have to prepare a rather large amount of seed data for a Rails application. Based on my limited experience, I know of two ways to do it but want to know which offers the most flexibility.

One, I could do it with Rails and just prepare the seed data the way it’s used in the seeds.rb file

User.create!( name: "John" ) 

Or, I could create a json document of the data. For example, I know that Mongodb lets you import json documents directly into the database. I’m not sure about other databases…

It occurred to me that a json document might be the most flexible, because I suppose you could also use a regular expression script to turn the json into something like this User.create!( name: "John" )

However, I’m wondering if there’s any other issues I should consider…

  • 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-06-17T22:17:10+00:00Added an answer on June 17, 2026 at 10:17 pm

    One issue to consider is that you can’t always pass all the parameters through the constructor. Consider this:

    class User
      include Mongoid::Document
    
      field :name
      field :role
    
      validates :name, presence: true
      validates :role, presence: true
    
      attr_accessible :name
    end
    

    If you have something like User.create({name: 'John', role: 'admin'}), then your seed will fail because role will not be able to be assigned.

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

Sidebar

Related Questions

Does anyone know how to prepare data to plot a CDF (I have a
I have to prepare a report which is getting some fields data from conf
I have a rather complicated toolchain so prepare for a lengthy post until getting
I have a C++ code and now I am thinking to prepare a UI
In Symfony 2 I have the following code in my Controller: // prepare to
I have this query and I have an error: images = Image.find_by_sql('PREPARE stmt FROM
I have this code, but i cant make it work: images = Image.find_by_sql('PREPARE stmt
I have a complex query that gets executed like this: if ($stmt = $dbi->prepare($pt_query))
I have the following code: <? $query =$db->prepare(INSERT INTO a_table (id, a_field) VALUES ('',
I have prepared one sample application.When application install in devices download the file from

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.