Using Rails 3.2.2 and Ruby 1.9.2.
I have a rail-mounted engine EngineAthat declares an inheriting form of a class User ActiveRecord::Base. I have another engine EngineBthat wants to add functionality to EngineA::User. Right now, what I did is shown below:
Method 1:
module EngineA
class User < ActiveRecord::Base
has_attached_file :avatar
has_many :somethings
end
end
module EngineB
module User
def self.extended obj
obj.class_eval do
has_many :something_elses
end
end
end
end
EngineA::User.extend EngineB::User
This gives me an error uninitialized constant EngineA::User. Even when I need this particular file, I run into a problem EngineArequiring a paper clip to understand has_attached_file. This road ended when I realized that I should know and demand addiction EngineAinside EngineB.
Method 2:
, , , EngineA::User.extend EngineB::User EngineB user.rb. EngineB.
EngineA::User.extend EngineB::User
!!! , , . , , EngineA::User, mixin, . , , .
, "" ... . .