two has_many association for a single model

Hi

I have following models

1. employee

2. transaction

Requirement - A transaction has a dealer(employee) and a
driver(employee).

I experimented following
---------

I have put -

/models/employee.rb :

has_many :transactions, :as => :dealer
has_many :transactions, :as => :driver

you're misusing :as here - that's for something completely different

/models/transaction.rb :

belongs_to :dealer, :class => :employee, :foreign_key => :employee_id
belongs_to :driver, :class => :employee, :foreign_key => :employee_id

Transaction table has columns - dealer_id, driver_id,

If that's the case then the :foreign_key option should be 'dealer_id'
and 'driver_id' (and thus unnecessary as that's the default).
The :class option is also supposed to be :class_name
I've got an example of something similar here: http://www.spacevatican.org/2008/5/6/creating-multiple-associations-with-the-same-table
Lastly, be wary of associations called transaction before Rails 2.3 -
the transaction method created by the association will stomp on an
internal method

Fred