So, I'm posting a reply to my own original post. I fixed my problem and
thought I'd follow up for posterity.

The pertinent broken code was:

 def self.included(base)
   base.send :extend,  ClassMethods
   base.send :include, InstanceMethods
   base.send :alias_method_chain, :belongs_to, :polymorphism
 end

The fixed code is:

 def self.included(base)
   base.send :extend,  ClassMethods
   base.send :include, InstanceMethods
   class << base
     alias_method_chain :belongs_to, :polymorphism
   end
 end

Calling alias_method_chain (or just alias_method for that matter) on the
class from "outside" (aka by klass.send :alias_method, ...) runs in the
wrong context. It wants to alias regular instance methods of the klass.
Instead, alias_method needs to happen in (still don't know proper ruby
terms for this stuff, sorry) *class* scope (???) so that it will look
for class methods to alias.

As an aside, I was quite retarded when, in my previous post, I ran the
following command in an attempt to see if the belongs_to method was in
fact defined:

ActiveRecord::Base.methods.find {|m| m =~ /belongs_to/}

If, of course, instead finds the first method that matches which was
`has_and_[i]belongs_to[/i]_many' in my case. I should've been using
[i]find_all[/i] instead. Well, yeah, just an FYI.

I originally wrote:
> http://www.ruby-forum.com/topic/187419
> (there, just saved a ton of space and a whole lotta money on
> my ___ _________ by switching to _____)
-- 
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