db:seed not loading models

后端 未结 3 411
轻奢々
轻奢々 2021-01-18 12:23

I\'m trying to seed my database with the standard db/seeds.rb method. This works fine on my development machine, but on my server, I get:

$ sudo         


        
3条回答
  •  礼貌的吻别
    2021-01-18 12:54

    In a comment to the blog posted linked to above and here again: http://www.builtfromsource.com/2011/02/09/getting-rake-dbseed-and-config-threadsafe-to-play-nice/

    Bruce Adams mentions that one can call:

    config.threadsafe! unless $rails_rake_task

    to only turn on threadsafe when not running a rake task.

    But as the issue is really that threadsafe turns off dependency_loading, you can simply add this line after config.threadsafe! to leave it enabled, but still load your environment as you expect.

    config.dependency_loading = true if $rails_rake_task

提交回复
热议问题