Created
September 4, 2013 20:00
-
-
Save victorhazbunanuff/6442092 to your computer and use it in GitHub Desktop.
cache
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
module AccountSupport::CacheManager | |
extend ActiveSupport::Concern | |
included do | |
# Returns the cached users of an account | |
def cached_users | |
Rails.cache.fetch("#{id}_account.users") { member_users.all } | |
end | |
# Returns the cached teammates of an account | |
def cached_teammates | |
Rails.cache.fetch("#{id}_account.teammates") { member_teammates.all } | |
end | |
# Return the cached projects of an account | |
def cached_projects | |
project_list = Rails.cache.fetch("#{id}_account.projects") { projects.entries } | |
project_list.accessible_by(ability).entries if account_member.is_client? | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
en el cached projects para clientes igual se hace una consulta para sacar los clientes del client...
ademas de eso, project_list es un array, no un active record relation, si funciona?