I have class in a plugin that I want to crack open and add some
functionality to for a particular application. So, I created a file by
the same name as the class in my app/models folder and added some
methods to the class, but, I can't seem to get Rails (2.2.2) to pick-up
the extended definition.

I did find while trying to debug the problem that if I paste the
extended definition into, say, environment.rb it works fine.  Also, if I
require_dependency "#{RAILS_ROOT}/app/models/my_class.rb" in the
plugin's version of the class it also works fine (obviously not
desirable).

All of this leads me to believe that my problem has something to do with
the class loader, but, I can't figure it out.  I've laid out an example
below that illustrates my problem. Any help would be much appreciated.

Thanks,
Jason


# vendor/plugins/my_plugin/init.rb
require 'my_plugin'

# vendor/plugins/my_plugin/lib/my_plugin.rb
module Jason
  class MyClass
    def a_method
      # ...
    end
  end
end

# app/models/my_class.rb
module Jason
  class MyClass
    def another_method
      # ...
    end
  end
end

$ script/console
>> Jason::MyClass.new.another_method
NoMethodError: undefined method `another_method' for
#<Jason::MyClass:0x408b444>
-- 
Posted via http://www.ruby-forum.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 [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to