ruby on rails - 'Company' and 'Person': threat them similar... but gives problems when creating forms -


our company can have contract person , company.

so responsible 'party' of contract, can both person , company.

i have setup 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 want able have form "new contract" , in field "contract with" i'd have dropdown box of known people , companies.

---

in end: i'm willing change model , ideas... behaviour should remain contract can closed both person , company. suggestion welcome!

you fill select values string containing both class , id (i.e. ), process in either model or controller.


Comments

Popular posts from this blog

c# - SharpSVN - How to get the previous revision? -

c++ - Is it possible to compile a VST on linux? -

url - Querystring manipulation of email Address in PHP -