2 foreign keys to one table

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

belongs_to :user, :foreign_key => “from_id”
belongs_to :user, :foreign_key => “to_id”

Would this work for you?

belongs_to :from, :class_name => ‘User’
belongs_to :to, :class_name => ‘User’

Cheers
Nic

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs