how to use several foreign key pointing to the same model?

Hey all, I have User has_many posts and Post belongs to a user. I have a Post that can be posted_by a User and deleted_by another User. So I'd like to do something like has_many posters and has_many deleters both pointing to the User models so I can do: @post=Post.find(:first) @deleter=Post.deleter.name pointing to User(@post.deleted_by).name and poster=Post.poster.name pointing to User(@post.posted_by).name

thanx in advance

Pat

You can tell AR which field to use as the foreign key for an association:

class Post belongs_to :poster, :class_name=>'User', :foreign_key=>'poster_id' belongs_to :deleted_by, :class_name=>'User', :foreign_key=>'deleted_by_id' end

class User has_many :posts, :foreign_key=>'poster_id' has_many :deleted_posts, :class_name=>'Post', :foreign_key=>'deleted_by_id' end

Cheers, Max

ok, thanx a lot Max!

Pat