2017-02-23 90 views
0
module Cequel 
    module Record 

    module Schema 
     extend ActiveSupport::Concern 
     extend Util::Forwardable 

     included do 
     class_attribute :table_name, instance_writer: false 
     self.table_name = name.demodulize.tableize.to_sym unless name.nil? || self.table_name.present? 
     end 
    end 
    end 
end 

我想猴子从该模块在我的Rails应用程序补丁included块,但是当我在初始化中轨定义相同的代码,我得到猴子修补块的一个模块中的红宝石

included': Cannot define multiple 'included' blocks for a Concern (ActiveSupport::Concern::MultipleIncludedBlocks)

This是我想要补丁修复,直到这个公关被合并,有没有办法补丁包含的块?

+1

你的公关被合并,所以只需指出你的宝石掌握... – Anthony

回答

1

您需要在初始化程序中从头开始。这就是说,你应该

Cequel::Record.send :remove_const, :Schema 

完全删除模块常量定义现在,您可以重新执行该代码段,定义Schema,只要你想:红宝石不知道这件事了。