Hi all!
I'm having trouble with the following code:
User < AR
acts_as_authentic
belongs_to :owner, :polymorphic => true
end
Worker < AR
has_one :user, :as => :owner
accepts_nested_attributes_for :user
end
Employer < AR
has_one :user, :as => :owner
accepts_nested_attributes_for :user
end
I'd like to create registration forms based on user types, and to include authentication fields such as username and password. I currently do this:
UserRegistrationController < AC
#i.e. a new Employer
def new
@employer = Employer.new
@employer.build_user
end
...
end
I then include User fields with fields_for
. All views render fine, but here's the catch: I cannot build a User, it tells me :password
is a wrong method, so I guess the authentication logic has been bypassed.
What should I do? Am I doing it wrong altogether? Should I drop polymorphic associations in favor of Single Table Inheritance? Whatever I do, I have to make sure it plays nicely with Authlogic.