From 55c63be9e243f4005468c6c1b3e1e0eb4c36e666 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A2u=20Cao?= Date: Wed, 28 May 2025 18:39:48 +0400 Subject: [PATCH] Memoize instance variable --- app/models/user.rb | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/app/models/user.rb b/app/models/user.rb index 4479800..ea05989 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -131,11 +131,11 @@ class User < ApplicationRecord end def is_admin? - admin ||= if admin = Devise::LDAP::Adapter.get_ldap_param(self.cn, :admin) - !!admin.first - else - false - end + @admin ||= if admin = Devise::LDAP::Adapter.get_ldap_param(self.cn, :admin) + !!admin.first + else + false + end end def address