I've read through countless blogs and the docs and can't seem to get
what I expect. I also tried irc on freenode, but they ignored me. I
must have a case of the mange or something.

I have a Person model (on a people table) and I want a hierarchy of
masters and servants. I'm doing this via a Vassalship model. When I
try to assign a master to a servant like so :

     juniorperson.master=seniorperson

I get NoMethodError: undefined method `update_attributes' for #<Class:
0x48be738>

And who knows what class that was. I can do
seniorperson.servants<<juniorperson   no problem, but then I get a nil
for juniorperson.master ?!?!

My models look like this :

class Person < ActiveRecord::Base
        
has_many :vassalships,:class_name=>'Vassalship',:foreign_key=>:master_id
        has_one :master,:through=>:vassalships,:source=>:master;
        has_many :servants,:through=>:vassalships,:source=>:servant;
end

class Vassalship < ActiveRecord::Base
        belongs_to :master,:class_name=>'Person',:foreign_key=>'master_id'
        belongs_to :servant,:class_name=>'Person',:foreign_key=>'servant_id'
end

my tables are here, if you need to see them: http://pastie.org/352858,
and the full console track is here : http://pastie.org/352871

I'm doing something wrong, but I don't know what. And anyone got a
better idea for the relationship? Vassalship seems a bit obscure.
--~--~---------~--~----~------------~-------~--~----~
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@googlegroups.com
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to