我正在创建一个 Rails 3.0.3 gem 并且无法让它工作:
# attached.rb
module Attached
require 'attached/railtie' if defined?(Rails)
def self.include(base)
base.send :extend, ClassMethods
end
module ClassMethods
def acts_as_fail
end
end
end
# attached/railtie.rb
require 'attached'
require 'rails'
module Attached
class Railtie < Rails::Railtie
initializer 'attached.initialize' do
ActiveSupport.on_load(:active_record) do
ActiveRecord::Base.send :include, Attached
end
end
end
end
undefined local variable or method 'acts_as_fail'
当我添加acts_as_fail
到我的任何ActiveRecord
模型时,我都会得到。请帮忙!我对这个看似微不足道的代码感到非常沮丧!谢谢!