Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我需要用表格等设置我的数据库,但在某些情况下,我不希望加载我的种子数据。db/seeds.rb每次我想忽略我的种子数据时,我也不想删除或移动我的文件。
db/seeds.rb
有没有办法执行rake db:setup和忽略种子数据的任务?
rake db:setup
是的。只需使用以下两个命令:
rake db:create rake db:schema:load
rake db:setup所做的只是创建数据库 ( ) ,从( )db:create加载数据,然后插入种子数据 ( )。您可以分别执行这些步骤。db/schema.rbdb:schema:loaddb:seed
db:create
db/schema.rb
db:schema:load
db:seed