# Undefined method in my plugin

**URL:** <https://www.ruby-forum.com/t/undefined-method-in-my-plugin/120129>\
**Category:** Rails\
**Created:** [November 14, 2007, 12:48am UTC](https://www.ruby-forum.com/t/undefined-method-in-my-plugin/120129 "2007-11-14T00:48:27Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![kevin\_ySkim](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/k/5daacb/32.png) [@kevin\_ySkim](https://www.ruby-forum.com/u/kevin_ySkim)\
**Post date:** [November 14, 2007, 12:48am UTC](https://www.ruby-forum.com/t/undefined-method-in-my-plugin/120129/1 "2007-11-14T00:48:27Z")

</div>

I’ve got a plugin that is really a collection of plugins, and I want  
one plugin to see methods from another.  
I’ve tried to simplify what I’ve done and what I’m seeing

So my (simplified) file structure looks like this:  
acts\_as\_foobar/

- init.rb
- lib/  
acts\_as\_foobar.rb  
foo.rb  
bar.rb

init.rb:  
require ‘acts\_as\_foobar.rb’

acts\_as\_foobar.rb:  
require ‘foo’  
require ‘bar’

foo.rb:  
module Foo  
def self.included(base)  
base.extend(ClassMethods)  
end

```
  module ClassMethods
    def acts_as_foo
      class_eval do
        extend Foo::SingletonMethods
      end
    end
  end

  module SingletonMethods
    def static_foo_method
      ...do something foo-ish here...
    end
  end
end

ActiveRecord::Base.send(:include, Foo)

```

bar.rb:  
module Bar  
def self.included(base)  
base.extend(ClassMethods)  
end

```
  module ClassMethods
    def acts_as_bar
      include Bar::InstanceMethods
    end
  end

  module InstanceMethods
    def instance_bar_method
      X.static_foo_method
    end
  end
end

ActiveRecord::Base.send(:include, Bar)

```

Now, I have two model classes, X and Y  
X.rb  
class X \< ActiveRecord::Base  
acts\_as\_foo  
end

Y.rb  
class Y \< ActiveRecord::Base  
acts\_as\_bar  
end

Now if I try this:  
Y.find(1).instance\_bar\_method

I’ll get an error like this:  
‘undefined method `static\_foo\_method’ for Foo:Module  
(NoMethodError)

But I can call  
X.static\_foo\_method  
and get the results I expect.

(I know this use of a plugin may not be optimal)

Any clues as to how I can get this work?

Thanks,  
-kevin
