How to use seed.rb to selectively populate development and/or production databases?

前端 未结 3 1776
自闭症患者
自闭症患者 2021-01-30 10:25

I am using seed.rb to populate both my development and production database. I usually populate the first with dummy data and the latter with the real minimal data that my app ne

3条回答
  •  不要未来只要你来
    2021-01-30 10:58

    seeds.rb is just a plain ruby file, so there are several ways you could approach this. How about a case statement?

    # do common stuff here
    
    case Rails.env
    when "development"
       ...
    when "production"
       ...
    end
    

提交回复
热议问题