开发者

Rails 3 + Devise: undefined variable or method 'record' in SessionsController

Hey, I defined the following method in my SessionsController to sign someone out:

def destroy
current_user.update_attribute(:signed_in => false) if record.respond_to?(signed_in?)
signed_in = signed_in?(resource_name)
sign_out_an开发者_StackOverflow中文版d_redirect(resource_name)
set_flash_message :notice, :signed_out if signed_in
end

but I always get this error:

undefined local variable or method `record' for #<Devise::SessionsController:0xbcd9780>

Seems to me that record.respond_to? tries to access ActiveRecord but can't. What should I do?


You can use the try method.

current_user.try("signed_in=", false); current_user.save
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜