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

/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,
------------------
Now the problem is how can I get something like @transaction.dealer.name
or
employee.transactions

------------
I certainly know that my experiment has basic flaws of understanding
associations.

Please help me!
-- 
Posted via http://www.ruby-forum.com/.

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to