-1

what is the relationship between db/seeds.rb and db/schema.rb? And How do I use them ? by the way,

# db/seeds.rb

Todo.create!(title: 'grocery shopping', notes: 'pickles, eggs, red onion')
Todo.create!(title: 'wash the car')
Todo.create!(title: 'register kids for school', notes: 'Register Kira for Ruby Junior High and Caleb for Rails High School')
Todo.create!(title: 'check engine light', notes: 'The check engine light is on in the Tacoma')
Todo.create!(title: 'dog groomers', notes: 'Take Pinky and Redford to the groomers on Wednesday the 23rd')

I can't understand 'notes'

wind
  • 440
  • 4
  • 14
  • Refer http://stackoverflow.com/questions/13789143/what-is-the-function-of-the-seeds-rb-file – Vaibhav Mule May 23 '15 at 09:33
  • 3
    Did you tried googling atleast before posting here ? A simple google search with seeds.rb - rails gives me the following - http://www.xyzpub.com/en/ruby-on-rails/3.2/seed_rb.html and http://edgeguides.rubyonrails.org/active_record_migrations.html – Caffeine Coder May 23 '15 at 09:35

2 Answers2

1

The seed.rb helps you to initialize data into your db.

You can run the file by:

rake db:seed

or run

rake db:setup

to create db, run migrations, and run seed

Shalev Shalit
  • 1,945
  • 4
  • 24
  • 34
0

Let's say you create a db and you can fill it with seeds.rb. In other words, you fill your tables in accordance with the model you generated beforehand.

User.create (username: "tony", password: "12345666")
User.create (username: "Clara", password: "fdvfdvfd666")
User.create (username: "Hans", password: "1gbfdbg2345666")
Voontent
  • 719
  • 5
  • 8