Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/ruby-on-rails/58.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ruby on rails Ruby on Rails中db文件夹中的seeds.rb是什么?_Ruby On Rails - Fatal编程技术网

Ruby on rails Ruby on Rails中db文件夹中的seeds.rb是什么?

Ruby on rails Ruby on Rails中db文件夹中的seeds.rb是什么?,ruby-on-rails,Ruby On Rails,db/seeds.rb和db/schema.rb之间的关系是什么?我如何使用它们?顺便说一下 # 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 Rub

db/seeds.rb和db/schema.rb之间的关系是什么?我如何使用它们?顺便说一下

# 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')

我无法理解“notes”

seed.rb帮助您将数据初始化到数据库中

您可以通过以下方式运行该文件:

rake db:seed
或运行

rake db:setup

要创建数据库,请运行迁移,然后运行seed

假设您创建了一个数据库,可以用seeds.rb填充它。换句话说,您可以根据事先生成的模型填充表格

User.create (username: "tony", password: "12345666")
User.create (username: "Clara", password: "fdvfdvfd666")
User.create (username: "Hans", password: "1gbfdbg2345666")

在这里发布之前,你是否至少尝试过谷歌搜索?使用seeds.rb-rails进行简单的谷歌搜索,我得到了以下信息