2

After updating to rails 3 authlogic does not work so i am using the gem 'authlogic', :git => 'git://github.com/odorcicd/authlogic.git', :branch => 'rails3'

This works for the standard setup but i have a multi account setup and i used with_scope before so a user can only login to their account / subdomain and not any account / subdomain.

This code in my application controller was working before but not now as uses the old find and not the new arel syntax.

def current_user_session
    return @current_user_session if defined?(@current_user_session)
    UserSession.with_scope(:account_id => account_id) do
      @current_user_session = UserSession.find
    end
end 

Has any on managed to update this for rails 3 or found a fix ?

Please help !

Best regards Richard

rick
  • 463
  • 5
  • 23

1 Answers1

1

EDIT: Apparently, authlogic is kind of broken when it comes to with_scope. Check this for details, it may also help you: http://groups.google.com/group/authlogic/browse_thread/thread/41c8d2fc82e1b69c

Are you using authenticates_many? I had a similar problem just now (my model that identifies the account/subdomain is called Website, and I have a before filter that sets @website). To fix it, I did the following:

I added the :find_options => { :limit => 1 } to the authenticates_many

class Website < ActiveRecord::Base
  authenticates_many :user_sessions, :find_options => { :limit => 1 }

My user model has the usual validations_scope:

acts_as_authentic do |c|
  c.validations_scope = :website_id
end

And my current_user_session method became the following:

def current_user_session
  return @current_user_session if defined?(@current_user_session)
  @current_user_session = @website.user_sessions.find
end

Hope it helps.

Hugo Peixoto
  • 3,604
  • 2
  • 18
  • 12