After reading the source code of Authlogic I figured out that there's
a bug in the authenticates_many method. The problem is that if
no :find_options hash is provided, Authlogic will create a
named_scope, and then threat it as if it's a hash of find_options.
What I did to solve this was to give a fake :find_options scope hash.
The call in my Account model looked as follows:
authenticates_many :user_sessions, :find_options => { :limit => 1 }
Since we're only authenticating one record at a time, it doesn't
affect to add this scope to the conditions.
In both the new and create actions of the UserSessionsController
instead of using
@user_session = UserSession.new(params[:arg]
I loaded the Accounts model from a domain parameter and created the
new UserSession from there.
account = Account.find_by_domain(params[:domain])
@user_session = account.user_sessions.new(params[:arg])
After doing that my authentication worked fine. I hope you find this
helpful.
Regards,
Carlos Kirkconnell