gpt4 book ai didi

ruby-on-rails - Rails - 在模块上包含 Elasticsearch ?

转载 作者:行者123 更新时间:2023-12-03 01:07:28 26 4
gpt4 key购买 nike

是否有可能拥有

include Elasticsearch::Model
include Elasticsearch::Model::Callbacks

在一个模块上?怎么样?

最佳答案

您可以使用 included ActiveSupport::Concern block 包括这些模块

就像是:

module MyElasticSupport
extend ActiveSupport::Concern

included do
include Elasticsearch::Model
include Elasticsearch::Model::Callbacks
end

... some other code ...
end

class MyModel
include MyElasticSupport

... some other code ...
end

关于ruby-on-rails - Rails - 在模块上包含 Elasticsearch ?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25313984/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com