I'm creating a Rails 3.0.3 gem and can't get it to work:
# 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
I get undefined local variable or method 'acts_as_fail'
when I add acts_as_fail
to any of my ActiveRecord
models. Please help! I'm extremely frustrated with this seemingly trivial code! Thanks!
You're defining self.include
(4th line down), when the correct method is self.included
.