try:

class Person < ActiveRecord::Base

 
has_many :vassalships,:class_name=>'Vassalship',:foreign_key=>'master_id'
        has_many :vassalship_belongings, :class_name =>
'Vassalship', :foreign_key => 'slave_id'
        has_one :master,:through=>:vassalships,:source=>:person
 
has_many :servants,:through=>:vassalship_belongings,:source=>:person
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

On Jan 6, 12:00 pm, itsastickup <[email protected]> wrote:
> I have a need for REST (as well as other things), as mentioned, and
> for that I require the go-between model. In anycase presumably my
> original question does have an answer, no? Perhaps :through does not
> work self-referentially, although I would be surprised. But the docs
> don;t have it and blogs haven't helped.
>
> On 5 Jan, 22:45, "Franz Strebel" <[email protected]> wrote:
>
> > On Mon, Jan 5, 2009 at 6:14 PM, itsastickup <[email protected]> 
> > wrote:
> > You only need one model, Person should suffice:
>
> > class Person < ActiveRecord::Base
>
> >   belongs_to :master, :class_name => 'Person', :foreign_key => 'master_id'
>
> >   has_many :servants, :class_name => 'Person', :foreign_key => 'master_id'
>
> > end
>
> > Let me know how you get on.
>
> > Regards,
> > Franz
--~--~---------~--~----~------------~-------~--~----~
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