You can do that or use acts_as_tree. acts_as_tree just sets up the
has_many and belongs_to relationships automatically, and I like using
it because it helps me immediately identify models which reference
themselves. The default foreign key name is parent_id, but I''d guess
you use :foreign_key => "referred_by" to do what you need.
On 8/2/05, Elliot Bowes <eblists-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
wrote:> Hi
>
> I have a table called candidates, which has a referred_by field which
> stores the ID of another candidate, or a null value, effectively
> linking the table to itself.
>
> How do I handle this link with rails?
>
> Can I just do a belongs_to and has_many specifying a foreign key, or
> do I need to do something else?
>
> Thanks
>
> Elliot
> _______________________________________________
> Rails mailing list
> Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org
> http://lists.rubyonrails.org/mailman/listinfo/rails
>