ruby - How to work with not (yet) registered devise Users -


i have user model, login , registration, email field used (everything vanilla devise gem).

i want (other) users able e.g. add users team, email-address identifier.

that fine when user existing (pseudo @team.users.add(user.find_by(email: other_users_email))) unsure how handle situations user not yet exist (did not [yet] register). when (new) user sets new account, example above after successfull registration current_user.teams should show correctly.

i not want force these potentially new users use system (e.g. using devise_invitable) , bother them email.

i followed path of creating user when user given email not yet exist, when user tries setup account, fails (email not unique).

alternatively, remodel teammember-part , let optionally either store email-adress or reference existing user. need check "open" teammembers directly after user-account-creation (so, teammembers given email). on each requst, looks expensive me. there might race conditions, live (and check every-now-in-a-millenia-gap cron-job).

any pointers? sure not unusual.

i'd this:

when user adds user b team email, create object user b, set flag, auto_created_and_inactive: true

when user b signs on site, have handle in users#create: first, try find auto-created record , update (set password or whatever; reset flag). or otherwise proceed usual route of creating new record.


Comments

Popular posts from this blog

How has firefox/gecko HTML+CSS rendering changed in version 38? -

javascript - Complex json ng-repeat -

jquery - Cloning of rows and columns from the old table into the new with colSpan and rowSpan -