0

Our company can have a contract with a person and a company.

So the responsible 'party' of a contract, can be both a person and a company.

I have setup a model where:

---

Contract ------ person | -- company

class Contract < ActiveRecord::Base belongs_to :party, :polymorphic => true end

class Party < ActiveRecord::Base self.abstract_class = true has_many :contracts, :as => :party end

class Organization < Party end

class Person < Party end

---

What I want to be able to do is have a form "new contract" and in the field "contract with" I'd like to have a dropdown box of all known people and companies.

---

In the end: I'm willing to change my model and ideas... but the behaviour that should remain is that a contract can be closed with both a person and a company. Any suggestion is welcome!

1 Answer 1

0

You could fill your select values with a string containing both class and id (i.e. ), which you then process in either the model or controller.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.