Tim Sullivan
Tim Sullivan

Reputation: 16888

Using Authlogic with a User model that isn't called "User"

I have an application that tracks people, but all those people are, possibly, users of the product. I'd rather have the model called Person (rather than User), but can't seem to figure out how to indicate to Authlogic that I'm using Person instead of User.

I'm sure it's somewhere obvious that I'm just not seeing, but I've been pouring over things for hours now and I'm giving up. :-)

Upvotes: 0

Views: 602

Answers (3)

techpeace
techpeace

Reputation: 2644

You just need to use the authenticate_with method inside of your session class, like so:

class CaseWorker < ActiveRecord::Base 
 acts_as_authentic do |c| 
   c.session_class = 'Session' 
 end 
end 

class Session < Authlogic::Session::Base 
  authenticate_with CaseWorker 
end 

The above code was lifted from this discussion.

Upvotes: 2

don
don

Reputation: 11

The name of the model class is inferred from the name of the session class that you derive from Authlogic::Session::Base.

class UserSession < Authlogic::Session::Base goes with the Users model.

class PersonSession < Authlogic::Session::Base should bind up to your Person model.

At least, that is what worked for me after an hour of digging through Authlogic's poor documentation.

Upvotes: 1

sikachu
sikachu

Reputation: 1221

I think you can just add acts_as_authentic in the Person model, and everything should work just fine. If you face anything says User in the documentation, then just change them to Person

Upvotes: 2

Related Questions