只是希望有人可以解釋這對我來說..的Rails/Ruby的密新帶來不必要的其他類中的方法
我有進口的模塊站點類:
網站
class Site < ActiveRecord::Base
include TrackableChanges
...
in trackable_changes.rb
我有此代碼..
module TrackableChanges
include ActiveSupport::Callbacks
def self.included(base)
# Initialize module.
base.has_many :change_requests, :as => :model, :dependent => :destroy
#Callbacks
base.before_save :before_save_change_request
base.after_save :after_save_change_request
base.before_destroy :before_destroy_change_request
Facility
end
...
參考設施真的讓我感到困惑(我在這裏放了一個簡單的參考..)。基本上在Facility.rb我有這個..
class Facility < ActiveRecord::Base
acts_as_citier
acts_as_citier看起來有點像這樣:
module Citier
def self.included(base)
# When a class includes a module the module’s self.included method will be invoked.
base.send :extend, ClassMethods
end
end
ActiveRecord::Base.send :include, Citier
現在..只要按我最初的模塊中引用設施它要在acts_as_citier寶石和延伸我的網站類的ActiveRecord。我希望act_as_citier gem適合我的設施,但不適合我的網站。
任何人都可以幫助阻止這包括引入這個不必要的參考!
編輯
好像我不能引用類的設施都沒有它帶來了在該基金定義通過它的參考寶石act_as_citier
城市做的ActiveRecord類添加劑這...
ActiveRecord::Base.send :include, Citier
請[不要在您的帖子中使用簽名或標語](http://stackoverflow.com/faq#signatures)。 – meagar