I have some code in an engine plugin that includes some models. In my application, I want to expand one of these models. I managed to add instance and class methods to the model in question by including the module from the initializer.
However, I cannot add associations, callbacks, etc. I get a "method not found" error.
/libs/qwerty/core.rb
module Qwerty
module Core
module Extensions
module User
module ClassMethods
has_many :hits, :uniq => true
before_validation_on_create :generate_code
def something
"something"
end
end
def self.included(base)
base.extend(ClassMethods)
end
end
end
end
end
/initializers/qwerty.rb
require 'qwerty/core/user'
User.send :include, Qwerty::Core::Extensions::User
source
share