假设我有这些定义:
module Votable
def self.included(klass)
klass.class_eval do
has_many :votes
end
end
end
class Post < ActiveRecord::Base
include Votable
end
Votable
模块包含在gem中,因此我无法修改源代码。我想将:dependent => :nullify
的默认行为覆盖为:dependent => :destroy
,就好像它是这样:
class Post
include Votable
has_many :votes, :dependent => :destroy
end
我将如何做到这一点?