attribute_fu プラグインに次のコードが表示されます。
module AttributeFu
module Associations #:nodoc:
def self.included(base) #:nodoc:
base.class_eval do
extend ClassMethods
class << self; alias_method_chain :has_many, :association_option; end
class_inheritable_accessor :managed_association_attributes
write_inheritable_attribute :managed_association_attributes, []
after_update :save_managed_associations
end
end
...
end
end
交換しようとすると
class << self; alias_method_chain :has_many, :association_option; end
with: alias_method_chain :has_many, :association_option?
次のエラーが表示されます
/usr/lib/ruby/gems/1.8/gems/activesupport-2.1.1/lib/active_support/core_ext/module/aliasing.rb:31:in `alias_method': undefined method `has_many' for class `ActiveRecord::Base' (NameError)
from /usr/lib/ruby/gems/1.8/gems/activesupport-2.1.1/lib/active_support/core_ext/module/aliasing.rb:31:in `alias_method_chain'
from /home/twong/git/physpace/vendor/plugins/attribute_fu/lib/attribute_fu/associations.rb:9:in `included'
この 2 行で同じことができると思ったのですが、間違っているようです。誰かが私のエラーを説明できますか?