Last active
May 22, 2018 04:36
-
-
Save jeremygottfried/22f15048ad2659e13eaa6b6d52239f71 to your computer and use it in GitHub Desktop.
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
#controllers/user_controller.rb | |
class UserController < ApplicationController | |
def index | |
users = User.includes(:posts) | |
json = Rails.cache.fetch(User.cache_key(users)) do | |
users.to_json(include: :posts) | |
end | |
render json: json | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment