[Rails] 2 foreign keys to one table

scott rm at urbandream.net
Mon Aug 14 15:14:53 GMT 2006


Hi,

I have a messaging class that has to relationships to one table

belongs_to :user, :foreign_key => "from_id"
belongs_to :user, :foreign_key => "to_id"

At the min I can specify message.user.login and it will return the 
username of last relationship to that table.
how can I get it to bring back both references
ie message.from.login and message.to.login

thanks
scott

-- 
Posted via http://www.ruby-forum.com/.


More information about the Rails mailing list