Skip to content

Instantly share code, notes, and snippets.

@victorhazbunanuff
Created September 4, 2013 20:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save victorhazbunanuff/6442092 to your computer and use it in GitHub Desktop.
Save victorhazbunanuff/6442092 to your computer and use it in GitHub Desktop.
cache
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
@miguelperez
Copy link

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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment