4 ms·
Why not just create a User model that has a null username and password field? If they sign up, you fill in those attributes. No need for a second table!
by EvilTrout 15y ago
Why not just create a User model that has a null username and password field? If they sign up, you fill in those attributes. No need for a second table!
- loquace 15y agoThis is the first question that came to my mind too. And it feels like a more accurate model of reality, since an anonymous user is a user, just without a username/password. You could model this in other ways on the User model too, like having a registered_at column, which, when blank, means an unregistered user. (In case, for example, you wanted to autogenerate a username for anonymous users, for display purposes.)
- choxi 15y agoThat's a good point, I just thought the model of having the identity be separate from the login credentials made more sense. It has some nice benefits to separate them mentioned by ch below.
- boucher 15y agoYup. That's what we do.
- ralphael 15y agoI like the original approach and the way an admin can impersonate a user is a nice win.