Christopher Meiklejohn's Tumblr

Aug 19

Authlogic in Rails 3

In the process of hacking authlogic to work with rails 3, I discovered a little gem that I thought I’d pass along:

It appears that the activerecord key method, which returns a primary key for a specific object, has been renamed to to_key, so the code needs to be adjusted accordingly:

http://github.com/cmeiklejohn/authlogic/commit/749c46c

1 2 3 
def to_key
  new_record? ? nil : [self.send(self.class.primary_key)]
end

Here’s my mostly working port — authentication works, but the generators are broken. Should be sufficient for getting authlogic running on an existing rails 2 app you are porting to rails 3, just not a new app: http://github.com/cmeiklejohn/authlogic

Posted via email from Christopher Meiklejohn | Comment »