开发者

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

I have an application that tracks people, but al开发者_StackOverflow中文版l 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. :-)


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


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.


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜