2015-02-23 46 views
0

我在Rails 3項目中使用了gem 'acts_as_tenant'Rails acts_as_tenant種子數據

每次添加新租戶時,我都想收集新的數據 - 但僅限於新租戶。

有沒有辦法將一個變量傳遞給rake db:seed

喜歡的東西:

rake db:seed -tenant=5 

感謝您的幫助!

回答

0

這工作:

$ TENANT=5 rake db:seed 

在seed.rb:

statuscode = Statuscode.first_or_create(
    :tenant_id => ENV['TENANT'], 
    :statuscode => 'Completed', 
    :closed => true 
)