Correct me if I'm wrong here, but it sounds like companies won't be logging in — only users, which belong to a company.
With that in mind, you should have User
as the Devise model instead of Company
. Your associations, then, are correct. The next step would be to add fields for the user in the form for company#new
using nested attributes (fields_for
in the view; accepts_nested_attributes_for
in the model).
Answering your original question: you can use nested attributes to create a new user in the sign up form. You wouldn't need to override Devise's registration controller. Just modify the sign up form to include fields_for
a user. Also, make sure the Company
model has accepts_nested_attributes_for
for the User
model.
A quick aside: I'm not aware of the architecture of your application, but it seems like a has_many
would be more appropriate. In cases similar to this, it's far more likely that you'll want to have multiple users belonging to a single company.