从数据库中已有的数据创建种子文件 [英] Create seed file from data already in the database

查看:30
本文介绍了从数据库中已有的数据创建种子文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用 Rails 3.0.3 并且我的类别"表的数据已经存在于数据库中,但想从中创建一个种子文件.是否有任何 rake 任务会从这张表中为我生成种子.rb 格式?

I'm using Rails 3.0.3 and have data for my "categories" table already in the database, but want to create a seed file from it. Is there any rake task that will generate the seeds.rb format for me from this table?

推荐答案

有一个名为 seed_dump 的 gem,它完全可以满足您的需求:

There is a gem called seed_dump, which will do exactly what you want:

这篇关于从数据库中已有的数据创建种子文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆