Guest User

Untitled

a guest
May 26th, 2018
94
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.25 KB | None | 0 0
  1. #controllers/user_controller.rb
  2.  
  3. class UserController < ApplicationController
  4.  
  5. def index
  6. users = User.includes(:posts)
  7. json = Rails.cache.fetch(User.cache_key(users)) do
  8. users.to_json(include: :posts)
  9. end
  10. render json: json
  11. end
  12.  
  13. end
Add Comment
Please, Sign In to add comment