how to store/model users/faceboook users/linkedin users, etc, with ActiveRecord?

Posted by crankharder on Stack Overflow See other posts from Stack Overflow or by crankharder
Published on 2010-01-21T00:24:34Z Indexed on 2010/04/11 14:03 UTC
Read the original article Hit count: 284

Filed under:
|

My app has

  • "normal" users: those which come through a typical signup page
  • facebook(FB) users: those which come from Facebook connect
  • "FB-normal" users: a user that can log with both email/password * FB connect

Further, there's the a slew of other openID-ish login methods (I don't think openID itself will be acceptable since it doesn't link up the accounts and allow the 3rd party specific features (posting to twitter, adding a FB post, etc etc))

So, how do I model this?

Right now we have User class with #facebook_user? defined -- but it gets messy with the "FB-normal" users - plus all the validations become very tricky and hard to interpret. Also, there are methods like #deliver_password_reset! which make no sense in the context for facebook-only users. (this is lame)

I've thought out STI (User::Facebook, User::Normal, User::FBNormal, etc.) This makes validations super slick, but it doesn't scale to other connection types, and all the permutations between them... User::FacebookLinkedInNormal(wtf?) Doing this with a bunch of modules I think would suck a lot.

Any other ideas?

© Stack Overflow or respective owner

Related posts about activerecord

Related posts about data-modeling