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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T15:27:00+00:00 2026-05-30T15:27:00+00:00

I have a new rails app with a fresh database and I want to

  • 0

I have a new rails app with a fresh database and I want to add some default entries, like admin with default password etc.

How should I proceed?

I know of two possibilities, that both have drawbacks:

  • Use ruby code in migration: User.create!(:email => “admin@example.com”, :password => “abc”)
  • Use SQL code in migration: INSERT INTO users (id, email, password) VALUES (1, ‘admin@example.com’, ‘abc’)

The first alternative can break if I alter my code in later versions. The second is somewhat DBMS dependent.

As I do not plan to change my database, I would go with SQL code, but are there better alternatives?

  • 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-30T15:27:02+00:00Added an answer on May 30, 2026 at 3:27 pm

    Personally I’d use seed data

    http://railscasts.com/episodes/179-seed-data

    One advantage of this is that rake db:setup calls rake db:seed after it has created the database. Which is perfect for new machines.

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

Sidebar

Related Questions

New to rails here: I have a rails app and I'd like to place
I have a Rails app (Postgres) and I want to add validation based on
I have this new Rails app. I installed Devise. I don't want people registering
Starting a new rails project and we have a well-thought-out color palette, and want
I have a new rails app which needs to access data from a legacy
I have a simple rails app using devise--as such (and being a new rails
I have created a new rails app (3.2.8) using Devise. All is setup properly,
I have a Rails 3 app. Using the default logging config, when I issue
i tried setting up devise with a brand new rails app, i have devise
I have a new app (Rails 2.3.8) that uses lots of money fields. I'm

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.