This isn't has_many :through, it's just a simple has_many association.
class User has_many :sent_messages, :class_name => 'Message', :foreign_key => 'sender_id' has_many :received_messages, :class_name => 'Message', :foreign_key => 'receiver_id' end
class Message belongs_to :sender, :class_name => 'User' belongs_to :receiver, :class_name => 'User' end