Can I pass an argument to rake db:seed?

前端 未结 1 1941
盖世英雄少女心
盖世英雄少女心 2021-01-31 16:42

Part of my seeds.rb loads a lot of data into the database. I want to be able to selectively load this data. E.g.

$ rake db:seed

o

相关标签:
1条回答
  • 2021-01-31 17:29

    Rake arguments are painful to pass around, unfortunately (and db:seed doesn't pass its arguments through, regardless).

    Your best bet is to use environment variables to pass your extra args through:

    rake db:seed minimal=yes
    

    and

    unless ENV["minimal"]
      # do stuff
    

    etc

    0 讨论(0)
提交回复
热议问题