# Plugin Namespace Oddities?

**URL:** <https://www.ruby-forum.com/t/plugin-namespace-oddities/62510>\
**Category:** Rails\
**Created:** [June 5, 2006, 6:32pm UTC](https://www.ruby-forum.com/t/plugin-namespace-oddities/62510 "2006-06-05T18:32:13Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![matthewmurcia](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/7cd45c/32.png) [@matthewmurcia](https://www.ruby-forum.com/u/matthewmurcia)\
**Post date:** [June 5, 2006, 6:32pm UTC](https://www.ruby-forum.com/t/plugin-namespace-oddities/62510/1 "2006-06-05T18:32:13Z")

</div>

Hi all,

I’m trying to throw together an acts\_as\_copyable, to add the ability to:

@new\_ar\_object = @ar\_object.copy

I’m using the Fox example for the basic loading into AR with a module:

[http://wiki.rubyonrails.org/rails/pages/HowToWriteAnActsAsFoxPlugin](http://wiki.rubyonrails.org/rails/pages/HowToWriteAnActsAsFoxPlugin)

so in my instance methods:

```
  module InstanceMethods
    def copy( options = {} )
      copyable_attributes = self.attributes
      copyable_attributes.delete 'id'
      options.each do |key, value|
        next if key.class == String
        options.delete key
        options[key.to_s] = value
      end
      copyable_attributes.merge! options
      logger.info self.class.to_s
      new_copy = self.class.send :new, copyable_attributes
      new_copy.save
    end
  end

```

Originally I was calling self.create, but that failed as well. Rails is  
tossing my to an error page claiming:

undefined method `datatype’ for false:FalseClass

however, in my log, the self.class.to\_s is Datatype, which should load  
the  
Datatype class. IRB shows this:

irb(main):001:0\> class Foo  
irb(main):002:1\> def hello  
irb(main):003:2\> puts ‘hello  
irb(main):004:2’ ’  
irb(main):005:2\> end  
irb(main):006:1\> def self.whoa  
irb(main):007:2\> puts ‘whoa’  
irb(main):008:2\> end  
irb(main):009:1\> end  
=\> nil  
irb(main):010:0\> a = Foo.new  
=\> #Foo:0x402d862c  
irb(main):011:0\> a.send :hello  
hello  
=\> nil  
irb(main):012:0\> a.send :whoa  
NoMethodError: undefined method `whoa' for #<Foo:0x402d862c> from (irb):12:in `send’  
from (irb):12  
from :0  
irb(main):013:0\> a.class.send :whoa  
whoa  
=\> nil

So, why doesn’t self.class.send work the same in a rails plugin? Why is  
Datatype being changed to datatype, and being called as a method, not a  
class definiton?

Thanks,

–  
Matthew B. :: 607 227 0871  
Resume & Portfolio @ [http://madhatted.com](http://madhatted.com)
