我正在尝试自动加载一个问题。以下文件保存为app / models / concerns / plutus_account_extenison.rb
module PlutusAccountExtension
extend ActiveSupport::Concern
included do
belongs_to :party, class_name: 'V1::Party'
end
end
Plutus::Account.send :include, PlutusAccountExtension
在加载时,上述问题不包含在Plutus :: Account模型中。我可以在rails console中包含这个问题。
[1] pry(main)> Plutus::Account.reflect_on_all_associations(:belongs_to)
=> []
[2] pry(main)> Plutus::Account.send :include, PlutusAccountExtension
=> Plutus::Account (call 'Plutus::Account.connection' to establish a connection)
[3] pry(main)> Plutus::Account.reflect_on_all_associations(:belongs_to)
=> [#<ActiveRecord::Reflection::BelongsToReflection:0x007fe9f5060130
@active_record=Plutus::Account (call 'Plutus::Account.connection' to establish a connection),
@association_scope_cache={},
@automatic_inverse_of=nil,
@constructable=true,
@foreign_type="party_type",
@klass=nil,
@name=:party,
@options={:class_name=>"V1::Party"},
@plural_name="parties",
@scope=nil,
@scope_lock=#<Mutex:0x007fe9f507be08>,
@type=nil>]
V