Files
nairobi/app/helpers/cache_keys_helper.rb
2015-09-06 22:03:31 +02:00

25 lines
706 B
Ruby

module CacheKeysHelper
def locale_and_user_status(authorable=nil)
@cache_key_user ||= calculate_user_status(authorable)
"#{I18n.locale}/#{@cache_key_user}"
end
def calculate_user_status(authorable=nil)
user_status = "user"
if user_signed_in?
user_status += ":signed"
user_status += ":verified" if current_user.verified_at.present?
user_status += ":org" if current_user.organization?
user_status += ":admin" if current_user.administrator?
user_status += ":moderator" if current_user.moderator?
user_status += ":author" if authorable && authorable.author == current_user
else
user_status += ":visitor"
end
user_status
end
end