Polymorphic associations ok in read but not in create


#1

Hi, I am trying to use polymorphic associations to solve the following
problem:
I want a general class ‘Employee’ which content can come from 2 other
classes.
The code is:

class Employee < ActiveRecord::Base

:assignable is the interface we expose to mask of various employee

types.
belongs_to :assignable, :polymorphic => true
end

class User < ActiveRecord::Base

polymorphic association

has_many :employees, :as => :assignable #here I am not sure if I should
put has_many or has_one ?
end

class Secretary < ActiveRecord::Base

polymorphic association

has_many :employees, :as => :assignable
end

In Read mode, everything is fine :
Employee.find(:first).class # => Employee.
Employee.find(:first).assignable.class # => User or Secretary ,
depending on the data.

Now, I am writing my Unit Tests and I want to see if when I create a
User, the Employee entry is also created or not.
Apparently, User.save does not create a record in Employee, which I mean
I have to code this.

Am I doing something wrong in my code or is it simply that it is not
[yet] implemented in Rails ?

thanks in advance.

Romain.