RESTful Authentication and dual login

Hello all,

I’m setting up a RIA with 2 separate “sub sites” (with namespaces in
the routes), let’s say one for the clients, the other for the
dealers.
I want to use RESTful authentication, have followed the nice tutorial
available here (http://railsforum.com/viewtopic.php?id=14216&p=1) and
it works perfectly, but it is not adapted to my dual login system, and
I’m really scratching my head to modify this. I come from a C++/PHP
background, so I’m still finding my marks around models, filters, REST
routes (ressources), etc.

So should I keep :

  • one “users” model, with 2 :has_one relationships (1 to clients
    model, 1 to dealers model, of course mutually exclusive) and a boolean
    in the users model to indicate if it’s a client or a dealer ;
  • or no users model but two totally separate and complete models
    (“clients” and “dealers”), with all user information in each, and only
    1 stored in the session, but then how could I know which one ? and
    that means no more current_user in the session but rather a
    current_client OR current_dealer ?

Help, I’m really stuck on that one, I can’t decide the most natural
(and most DRY) method of applying my “simple” business rule in a rails
2.0 environment.

Laurent Cortier.

My gut instinct is it’d be easier to have one user table.

Yes, I’m studying the STI way for now, even if only to add specialized
foreign keys to actual user data.
The problem here is that my gut instinct doesn’t work like it should
because Rails re-defines web programming following many design
patterns still not clearly assimilated by my own CPU :stuck_out_tongue:

My gut instinct is it’d be easier to have one user table.
-R

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs