新手问题 在执行 rake db:migrate 的时候怎么给表中插入一条记录?

kikyous · July 16, 2012 · Last by kikyous replied at July 16, 2012 · 2113 hits

rt

调用 Model.create 就可以了。 不过最好不要在 Migration 里面写数据插入,你可以写到 seeds 里面,然后用 rake db:seed 来运行

You need to Sign in before reply, if you don't have an account, please Sign up first.