Rails 3 loading all models on startup

后端 未结 3 1428
情书的邮戳
情书的邮戳 2021-02-05 18:32

I have a class method mixed in to all my models. the method gets called when the model class is evaluated. unfortunately (for me), this seems to be on-demand, whenever the model

3条回答
  •  暖寄归人
    2021-02-05 18:54

    The correct way to do this application-wide is to turn on cache_classes in your configuration. By default it's off in development but on in production.

    If you want to do it sporadically:

    Rails.application.eager_load!
    

提交回复
热议问题