我制造了一条简单的铁路,为积极通融增加了一只 st子:
0 module Searchable
1 class Railtie < Rails::Railtie
2 initializer searchable.model_additions do
3 ActiveSupport.on_load :active_record do
4 extend ModelAdditions
5 end
6 end
7 end
8 end
在申请被传唤之前,我要求(在校正/校正)在座标/环境。
require searchable
这在我的申请中发挥了巨大作用,没有重大问题。
然而,我遇到了一个 r问题:见到。
In my seeds.rb file, I read data in from a csv and populate the database. The problem I am having is that the additions I made to ActiveRecord don t get loaded, and seeds fails with a method_missing error. I am not calling these methods, but I assume that since seeds.rb loads the models, it tries to call some of the methods and that s why it fails.
任何人都能够告诉我,提出这种要求,以便每次都包括进来。 主动记录是装满的(不仅仅是装满申请时)? 我更愿意将守则置于我的模式之外,因为守则是我大多数模式之间共有的,我希望保持其清洁和危险。