Ruby on rails 轨道3和x2B;设计:未定义的变量或方法';记录';在会话控制器中

Ruby on rails 轨道3和x2B;设计:未定义的变量或方法';记录';在会话控制器中,ruby-on-rails,Ruby On Rails,哎,, 我在SessionController中定义了以下方法以注销某人: def destroy current_user.update_attribute(:signed_in => false) if record.respond_to?(signed_in?) signed_in = signed_in?(resource_name) sign_out_and_redirect(resource_name) set_flash_message :notice, :signed_ou

哎,, 我在SessionController中定义了以下方法以注销某人:

def destroy
current_user.update_attribute(:signed_in => false) if record.respond_to?(signed_in?)
signed_in = signed_in?(resource_name)
sign_out_and_redirect(resource_name)
set_flash_message :notice, :signed_out if signed_in
end
但我总是犯这样的错误:

undefined local variable or method `record' for #<Devise::SessionsController:0xbcd9780>
未定义的局部变量或方法“record”#

在我看来那张唱片。你有什么反应?试图访问ActiveRecord,但无法。我该怎么办?

您可以使用try方法

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

这给了我一个非常奇怪的错误: