I would like set up a polymorphic relation with accepts_nested_attributes_for. Here is the code:
class Contact
The above answer is great but not working with the setup shown. It inspired me and i was able to create a working solution:
works for creating and updating
class Job :true
attr_accessible :client_attributes
accepts_nested_attributes_for :client
def attributes=(attributes = {})
self.client_type = attributes[:client_type]
super
end
def client_attributes=(attributes)
some_client = self.client_type.constantize.find_or_initilize_by_id(self.client_id)
some_client.attributes = attributes
self.client = some_client
end
end