Created
December 17, 2010 09:42
-
-
Save spint/744714 to your computer and use it in GitHub Desktop.
Caching 'false' in an instance variable in ruby (rails)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# this only gets cached in @admin if true | |
# how to cache this also in case of false? | |
def admin? | |
@admin ||= has_role? 'admin' | |
end | |
#is the following ok? | |
def admin? | |
return @admin if defined? @admin | |
@admin ||= has_role? 'admin' | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment