假设我有这些定义:
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 中,因此我无法修改源代码。我想覆盖 to 的默认行为,:dependent => :nullify
就:dependent => :destroy
好像它是这样的:
class Post
include Votable
has_many :votes, :dependent => :destroy
end
我该怎么做呢?