I am attempting to create a plugin, with some methods in my own module.
These would then be included to various pieces of active record. This works
fine when including them in classes, but when including them in a module,
the classes which include that module do not get the methods. These classes
do however get them when directly reopening the module. Is there any way
around this, or is it best to just reopen the module and define the new
methods?
Here is a stripped down example of the problematic code...
module A
def test
"test"
end
end
class B
include A
end
>> B.new.test
=> "test"
module C
def test_two
"test_two"
end
end
A.send :include, C
>> B.new.test_two
NoMethodError: undefined method `test_two'' for #<B:0xa7b8ddbc>
class D
include A
end
>> D.new.test_two
=> "test_two"
HOWEVER....
module A
def test_two
"test_two_again"
end
end
>> B.new.test_two
=> "test_two_again"
--
Mark Van Holstyn
mvette13-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org
http://lotswholetime.com
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk
-~----------~----~----~----~------~----~------~--~---