data modeling - how to store/model users/facebook users/linkedin users, etc, with ActiveRecord? -
my app has
- "normal" users: come through typical signup page
- facebook(fb) users: come facebook connect
- "fb-normal" users: user can log both email/password * fb connect
further, there's slew of other openid-ish login methods (i don't think openid acceptable since doesn't link accounts , allow 3rd party specific features (posting twitter, adding fb post, etc etc))
so, how model this?
right have user class #facebook_user? defined -- gets messy "fb-normal" users - plus validations become tricky , hard interpret. also, there methods #deliver_password_reset! make no sense in context facebook-only users. (this lame)
i've thought out sti (user::facebook, user::normal, user::fbnormal, etc.) makes validations super slick, doesn't scale other connection types, , permutations between them... user::facebooklinkedinnormal(wtf?) doing bunch of modules think suck lot.
any other ideas?
i split concerns, seems doesn't make sense keep records have vastly different fields in 1 table.
just have 1 user model/table doesn't save credentials, , make have has_many relationship account/login method, use sti model different types.
class user < ar::b has_many :accounts end class account < ar::b;end class passwordaccount < account;end class googleaccount < account;end class facebookaccount < account;end …
Comments
Post a Comment