I have a model Message
:
class Message < ActiveRecord::Base
belongs_to ...
belongs_to ...
belongs_to :user
belongs_to :user, class_name: "User", foreign_key: "accepted_denied_by_user_id"
end
With this setup, if I call:
message.user.email
I get email of the user who accepted the message, but not who sent it.
If I remove this line:
belongs_to :user, class_name: "User", foreign_key: "accepted_denied_by_user_id"
and call:
message.user.email
I get the email of a user who sent out the message.
How can I get the email of the sender and also the recipient?
I tried
message.accepted_denied_by_user.email
but this leads to
undefined method `accepted_denied_by_user' for ...
Thank you.