I have Devise and CanCan working well with my app.
I have 2 models: Account (Company Name) and User(users that login).
Account has many Users.
User belongs to Account.
Check out these 2 iterations:
-
So the first time someone creates a user (someone subscribes, from a
SUBSCRIBE form), it’s supposed to create an account too and insert the
newly created account id into users’ account_id column. -
Then the first user can add more users and that same account id can
be used. (from an ADD USER form)
Number 2 I already got it working. I create the Account using the
console, and the user can login and add users with the same account id.
But I can’t do Number 1!!!
I’m trying to look for the registration_controller of devise but can’t
find it. I’m thinking about checking the route to find out if it comes
from new_user_registration then create account and add account_id to
user. If it comes from new_user, then just use the existing account_id.
Suggestions on how to go about this problem?