【问题标题】:What is the difference between "rake db:seed" and rake db:fixtures:load"“rake db:seed”和 rake db:fixtures:load 有什么区别
【发布时间】:2014-11-07 06:13:13
【问题描述】:

我是 Ruby 和 Rails 的新手,对某些事情感到好奇。

在我正在查看的两个不同教程中,他们使用不同的方法来使用基本测试信息填充数据库。

使用“rake db:seed”从文本文件中提取样本数据。

其他使用“rake db:fixtures:load”。

在我看来,他们似乎在做同样的事情。

是他们,还是我在这里遗漏了什么? (很有可能)

【问题讨论】:

    标签: ruby-on-rails rake fixtures


    【解决方案1】:

    rake db:seed 将数据从 db/seeds.rb 加载到数据库中。这通常用于开发和生产数据库。它是用于启动空应用程序的永久数据。更多信息here。

    rake db:fixtures:load 将测试装置加载到测试数据库中。这是仅供测试使用的临时数据。您可以将fixture 视为sample data。

    【讨论】:

    • 其实是rake db:seed(末尾没有's')
    猜你喜欢
    • 2015-05-25
    • 1970-01-01
    • 2012-04-30
    • 1970-01-01
    • 2011-04-27
    • 1970-01-01
    • 1970-01-01
    • 2015-04-26
    • 2016-08-21
    相关资源
    最近更新 更多