Rails 3 + Authlogic not working all of a sudden

Hey People,

I’ve been working on Rails 3.0.0 and Authlogic for quite a while now but
all of a sudden I can’t login into my application anymore.

After some research I found out that no sessions are stored into the db
anymore so I started the console and saw this:
ruby-1.9.2-p0 > u = UserSession.new({:username => ‘Test’, :password =>
‘test123’})
=> #<UserSession: {:username=>“Test”, :password=>""}>
ruby-1.9.2-p0 > u.save
NoMethodError: undefined method cookies' for "UserSession":String from /usr/local/rvm/gems/ruby-1.9.2-p0/gems/authlogic-2.1.6/lib/authlogic/session/cookies.rb:117:insave_cookie’
from
/usr/local/rvm/gems/ruby-1.9.2-p0/gems/activesupport-3.0.0/lib/active_support/callbacks.rb:414:in
_run_after_save_callbacks' from /usr/local/rvm/gems/ruby-1.9.2-p0/gems/activesupport-3.0.0/lib/active_support/callbacks.rb:93:inrun_callbacks’
from
/usr/local/rvm/gems/ruby-1.9.2-p0/gems/authlogic-2.1.6/lib/authlogic/session/callbacks.rb:87:in
after_save' from /usr/local/rvm/gems/ruby-1.9.2-p0/gems/authlogic-2.1.6/lib/authlogic/session/existence.rb:71:insave’
from (irb):19
from
/usr/local/rvm/gems/ruby-1.9.2-p0/gems/railties-3.0.0/lib/rails/commands/console.rb:44:in
start' from /usr/local/rvm/gems/ruby-1.9.2-p0/gems/railties-3.0.0/lib/rails/commands/console.rb:8:instart’
from
/usr/local/rvm/gems/ruby-1.9.2-p0/gems/railties-3.0.0/lib/rails/commands.rb:23:in
<top (required)>' from script/rails:6:inrequire’
from script/rails:6:in `’

To be honest I have no idea why this happens all of a sudden. Anyone ran
into the same problem?

Apparently, this part of the code causes the trouble:
def save_cookie
controller.cookies[cookie_key] = {
:value =>
“#{record.persistence_token}::#{record.send(record.class.primary_key)}”,
:expires => remember_me_until,
:domain => controller.cookie_domain
}
end

For some reason the “controller” variable is only a String. Couldn’t
find where it’s set but yeah… it’s a bit too deep in the Gem code so I
guess I need to switch to another authentification gem until this is
solved.

On 2 December 2010 16:49, Heinz S. [email protected] wrote:

For some reason the “controller” variable is only a String. Couldn’t
find where it’s set but yeah… it’s a bit too deep in the Gem code so I
guess I need to switch to another authentification gem until this is
solved.

Can’t you roll back in your source control system to a version that
worked and determine the cause of the problem that way? Or do you
think it was a change in your system (gem upgrade or whatever) that
caused the problem to appear.

Colin

Colin L. wrote in post #965721:

Can’t you roll back in your source control system to a version that
worked and determine the cause of the problem that way? Or do you
think it was a change in your system (gem upgrade or whatever) that
caused the problem to appear.

Colin

I did a rollback already but that didn’t help. So it can only have
something to do with the gems even though I have only one version of
Authlogic installed:
authlogic (2.1.6)

Any suggestions?

Removed and reinstalled all gems. Same… getting a bit desperate now.

Hi Heinz,

I’ve created a simple authlogic3 rails template that might help you get
started.

It basically creates and does everything for you, including creating the
models.

I don’t know if its useful, but it might be a good alternative if you’re
still stuck.

Warmest regards,
David

My problem disappeared after some weeks of ignoring it, still no
freaking idea what caused it and what made it disappear again but your
template looks very interesting. Will give it a try once it’s back :slight_smile:

I have the same issue, except instead of a string, it’s an object:

NoMethodError: undefined method `cookies’ for main:Object

from
/Library/Ruby/Gems/1.8/gems/authlogic-2.1.6/lib/authlogic/controller_adapters/rails_adapter.rb:13:in
send' from /Library/Ruby/Gems/1.8/gems/authlogic-2.1.6/lib/authlogic/controller_adapters/rails_adapter.rb:13:incookies’
from
/Library/Ruby/Gems/1.8/gems/authlogic-2.1.6/lib/authlogic/session/cookies.rb:117:in
save_cookie' from /Library/Ruby/Gems/1.8/gems/activesupport-3.0.3/lib/active_support/callbacks.rb:414:in_run_after_save_callbacks’
from
/Library/Ruby/Gems/1.8/gems/activesupport-3.0.3/lib/active_support/callbacks.rb:93:in
send' from /Library/Ruby/Gems/1.8/gems/activesupport-3.0.3/lib/active_support/callbacks.rb:93:inrun_callbacks’
from
/Library/Ruby/Gems/1.8/gems/authlogic-2.1.6/lib/authlogic/session/callbacks.rb:83:in
after_save' from /Library/Ruby/Gems/1.8/gems/authlogic-2.1.6/lib/authlogic/session/existence.rb:71:insave’
from (irb):10

Going to report as a bug