Using authlogic With a Model Other Than User?

0 views
Skip to first unread message

athem

unread,
Nov 26, 2009, 6:28:33 AM11/26/09
to Ruby on Rails: Talk
Hello,

I want to implement authentication using the authlogic gem in an
application that already implements a User model that I cannot
modify. The authlogic authentication would be for something like a
new AdminUser model, completely separate from the existing User model.

Since authlogic is installed as a gem on the server (and used by other
applications), the gem code itself cannot be modified.

Any tips for where to begin/how to approach this?

thanks.

Darian Shimy

unread,
Nov 26, 2009, 12:04:45 PM11/26/09
to rubyonra...@googlegroups.com
This sounds like a bad idea, however, you can pack the gems (move them
into the vendor directory) and modify them there. If you have to make
significant changes, you can always fork the code and create your own
gem.

Darian Shimy
--
http://www.darianshimy.com
http://twitter.com/dshimy
> --
>
> You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
> To post to this group, send email to rubyonra...@googlegroups.com.
> To unsubscribe from this group, send email to rubyonrails-ta...@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
>
>
>

Jeffrey L. Taylor

unread,
Nov 26, 2009, 12:52:39 PM11/26/09
to Ruby on Rails: Talk
What happens if you just add acts_as_authenticated to the AdminUser model? It
may take a little monkeying about to discover what AuthLogic is expecting the
other pieces to be named, like sessions. Give it a try. And report back here
on the list for the future.

Jeffrey

Billee D.

unread,
Nov 27, 2009, 3:33:52 AM11/27/09
to Ruby on Rails: Talk
Maybe a stupid question here, but could you not make AdminUser a
subclass of User and turn off the authlogic on User methods? I guess
what I'm asking here is are there certain design requirements in your
project which dictate that the AdminUser class *must* be separated
from the base User class?

It seems that if the AdminUser needs to be separate — and you need to
user authlogic — the logical choice would be to fork the gem and make
your modifications to that copy instead of monkeying around in the
official gem. It may also be easier to just add access control to the
existing User class which allows certain users to be Admins.

Just trying to wrap my head around this. :)
Reply all
Reply to author
Forward
0 new messages